question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I've got several blogs and a couple of them are pretty visited, with around 1,5 million uniques per month. I've never used a CDN on them, but I'm considering trying to set up an account on some of the platforms available that have good support in WordPress through plugins and a nice user community. I wonder though if t...
Most CDNs (including Amazon's Cloudfront, which is what I've used), allow origin pull, which essentially means that the CDN pulls the required entity from, in this case, your blog, the first time someone tries to access it. If use a caching plugin like wp-supercache, or w3 total cache, they integrate with CDNs like Clo...
Is it too late to use a CDN?
wordpress
So I've set up AJAX with Wordpress properly, having followed some good tutorials, and it's working great. One thing I can't quite work out is how to properly return either TRUE or FALSE from within the callback function. My php function is as follows: <code> function my_callback() { if(something()) { echo 'false'; } el...
this would work to: <code> function my_callback() { if(something()) { echo 1; } exit; //no text sent or even exit('0'); will work } </code> and in js: <code> var response = do_ajax(); if(response){ //do stuff } </code>
Wordpress AJAX - how to return true or false in the callback function
wordpress
So what is the best process for setting up a large community site using WordPress with git version control? Multiple people submitting changes etc, testing area and easy way to update the live site. How would you do it?
The most prudent way is to use a staging server. The workflow would be: DVCS (git, mercurial) Remote repository for multiple users (self hosted, github, bitbucket, etc,). Staging server, push master files to. If all is good send the files from staging to live. Some Notes: Have only one/two people actually manage the ma...
Versioning and your WordPress site?
wordpress
The following code hides "the_content" output <code> add_filter( "the_content", "cp_module_pcontent_post_content" ); function cp_module_pcontent_post_content($content){ global $post; global $cp_module_pcontent_hide; if(!in_array($post-&gt;ID,(array)$cp_module_pcontent_hide)){ return $content; } $c = '&lt;p&gt;' . get_o...
OK i found the answer. Thanks to @t31os and stackexchange-url ("his code"). This is what i did. Replaced this line <code> echo $requirement; </code> with <code> echo apply_filters('requirement','$requirement'); </code> And then again I replaced this first line <code> add_filter( "the_content", "cp_module_pcontent_post_...
What is the filter hook for custom fields content?
wordpress
I have a plugin and I would like to be able to run the post content through some filters before it is saved to the database. From looking at the plugin api , I see that two hooks that look like they might be helpful: <code> save_post wp_insert_post </code> The only problem is that it looks like <code> save_post </code>...
The wp_insert_post_data filter can do that: <code> add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 ); function filter_post_data( $data , $postarr ) { // Change post title $data['post_title'] .= '_suffix'; return $data; } </code>
How can I edit post data before it is saved?
wordpress
In a theme I am working on, the comments form (mostly sure they are both comments form) adds javascript to the header. <code> &lt;script type='text/javascript' src='http://[URL]wp-includes/js/l10n.js?ver=20101110'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='http://[URL]/wp-includes/js/comment-reply.js?ver...
You could remove scripts in the following manner. <code> function custom_remove_scripts() { wp_dequeue_script('comment-reply'); } add_action( 'wp_enqueue_scripts', 'custom_remove_scripts' ); </code>
Remove Javascript generated by Comments
wordpress
So, I have my custom post type with the slug /news . And I want my category view to be /news/category/CATEGORYID . For that I create my custom taxonomy: <code> add_action('init', 'create_allfilmnews_categories', 0); function create_allfilmnews_categories() { $labels = array( 'name' =&gt; _x( 'Categories', 'taxonomy gen...
Two things - I think the category URL would be: yourdomain.com/news_category/NEWS-CATEGORY-SLUG-HERE So for example if you created a category "top headlines" in your "news_category" taxonomy... it would look like this (assuming the slug for "top headlines" is "top-headlines"): /news_category/top-headlines/ The second t...
How to hook custom taxonomies to custom post types and make the permalinks work?
wordpress
I'm quite familiar with WordPress, but have just minimal experience with PHP frameworks such as Codeigniter. When building a custom application, say for example an invoicing system or time management app for my company, does it make sense to use WordPress as a framework, or would it be more advisable to use something l...
Most frameworks are specifically designed to easily handle a large range of applications, while WordPress is quite limited when it comes to using its API to create applications like the one you mentioned. If you want to compare WordPress as a PHP framework with existing popular frameworks, think of it as one of the wor...
Using WordPress as a Framework
wordpress
I create a function to filter the taxonomy query with this code <code> add_action('pre_get_posts', 'custom_taxonomy_query'); $option_taxposts_per_page = get_option('tax_posts_per_page'); function custom_taxonomy_query(&amp;$query) { global $option_taxposts_per_page; if (!is_admin() &amp;&amp; is_tax('feature') || is_ta...
Solved! I was using the wrong technique to create a custom query to my taxonomy instead of using the function above I create new function that use query_vars. Here is the code <code> function taxonomy_posts_order($query) { global $browsetype; $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonom...
Help With issue on pre_get_posts filter in taxonomy
wordpress
Anyone knows a theme that's not only close (like "smoothness"), but really aligns with the look and feel of the admin UI?
Related trac ticket: Bundled jQuery UI should have CSS
jQuery UI Theme that aligns perfectly with the admin UI
wordpress
I had a colleague create a new theme and while doing so he copied an old theme and made the changes necessary. Now, in many of the files, there are functions that contain the old theme name in the function call instead of the new theme name. Is this parameter used in WordPress for anything and I should therefore change...
You can leave it or change it, it doesn't matter as long as the theme files use the correct handle for the function. I would choose one name and convert the second version so all use the same name to keep it simple.
Functions containing parameter 'yourtheme'
wordpress
Question Does anyone know what plugin Automattic uses for their eCommerce functionality in the MU installation of WordPress located on the free sub-domains at wordpress.com? Please share where it is available, or if it even is available. I suspect that it might be proprietary, but if not, I like to try and follow Autom...
According to Dion Hulse of Automattic : 100% custom, most ecommerce plugins of the time (many years ago) were not suitable for the use, its not opensource either
Automattic's eCommerce Plugin
wordpress
I want to create a multiple subdomains, but using only one wordpress and database installation. The difference of those subdomain sites are the colors and the blogs, but in terms of functionalities, layout, plugins, they are just the same. Is this possible, or can I only go with the ratio 1 is to 1 (1 wordpress for 1 s...
you can achieve that in many ways, maybe the most suitable for you is to use the multisite function in WordPress 3.0 Read more at WordPress.org : Create a Newtwork Migrating Multiple Blogs into WordPress 3.0 Multisite
One WordPress and database but multiple subdomains
wordpress
My WordPress site seems to be running fine, except that trying to go to the plugins page gives the following error: <code> Fatal error: Cannot redeclare _verifyactivate_widgets() (previously declared in .../public_html/wp-content/themes/news-child/functions.php:75) in .../public_html/wp-content/themes/news/functions.ph...
As the error says you cannot redeclare a function. You need to open your child theme's functions.php and remove the <code> _verifyactivate_widgets() </code> function from it. If you have copied the functions.php from the parent theme then most probably you would have to remove all the functions from the file unless any...
Looking for Functions File that doesn't Exist
wordpress
I searched for all kind of solution but i really could find one that did what i was looking for, what i simple want done is wrapping all images inside a div element, old post aswell as new posts. All help is very much appreciated p.s. I did a little jquery snippet but I really would like another solution the jquery cod...
Try using PHP's regular expression find/replace function— <code> preg_replace() </code> —in a filter on the <code> the_content </code> hook. <code> function breezer_addDivToImage( $content ) { // A regular expression of what to look for. $pattern = '/(&lt;img([^&gt;]*)&gt;)/i'; // What to replace it with. $1 refers to ...
Wrap all post images inside a div element
wordpress
I'm having trouble getting the second argument in wp_enque_style. Here's how my site is setup: style.css custom_style.css index.php In a template, I have this code: <code> $stylesheet_url = bloginfo('template_directory') . '/custom_style.css'; wp_enqueue_style( 'custom_style', $stylesheet_url ); </code> Which isn't wor...
To enqueue extra styles you should place the following code in your functions.php <code> function my_custom_styles() { wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom_style.css'); } add_action( 'wp_print_styles', 'my_custom_styles' ); </code>
getting url in wp_enqueue_style
wordpress
With <code> wp_dropdown_pages(); </code> it's able to make a dropdown list with the pages of the blog. How can I work with this function? I want to get a specific custom field of the "dropdown-selected page". Don't know the way so solve this problem.
Not sure what your trying to do with the custom field but you can create your own drop down select using the <code> get_pages() </code> function which returns an array of pages similar to the <code> get_posts() </code> function. <code> $pages = get_pages(); foreach( $pages as $page ) { echo get_post_meta( $page-&gt;ID,...
working with result of wp_dropdown_pages()
wordpress
I am trying to get the path to the themes CSS file from inside a Plugin, anyone know how to do this?
Get the absolute path: get_stylesheet_directory() Get the URI: get_stylesheet_directory_uri() Edit: Here's a proof of concept plugin. It will just print out the stylesheet path and uri in the head tag of your site (front end). If these functions are not working in your plugin, there might be some other factor not expla...
Get path to themes CSS file inside of a Plugin
wordpress
I created a custom "events" post type for a client that basically "hides" the post once it has expired (ie. the event already happened). The events are displayed in the order of the start date rather than the order that they are posted in. This is, ultimately, all working fine. However, now that we're closing in on the...
I ended up solving this by doing essentially one thing in a couple places. Wordpress doesn't let you specify a particular type for your meta data and stores everything as strings. As such, I added an extra meta data field that I used as the actual timestamp (using strtotime to convert it to a unix numeric timestamp) th...
Custom Post Type + Custom Meta Query Not Showing 2012 Posts
wordpress
I'm currently using Ian Stewart's A Sample WordPress Theme Options Page trying to create an inputfield and two textareas. Probably overlooking something somewhere I seem to be having some difficulties adding the second textarea. Does someone know what I'm doing wrong perhaps? Here's the code I'm currently using: <code>...
Not entirely sure if this would be the best way to answer my own question. As told by @goto10 and @maisdesign there is indeed nothing wrong with the code snippet above. Above article however uses <code> require_once </code> to load the <code> theme-options.php </code> . Using <code> include_once(get_stylesheet_director...
Creating a theme options page
wordpress
The function below is inside a single post loop. I have an array of IDs in a custom field. Such IDs represent related posts. I'm using Advanced Custom Fields (ACV) plugin and I manage the custom metas with it. In this case, to get the related_content meta, I can use the ACV function get_field('related_content') and gra...
I answer to myself, since this code is working better (previous had an issue) and also I removed a useless "for": <code> echo '&lt;ul class="related-content"&gt;'; $count = 0; foreach(get_field('related_content') as $post_object) : $count++; if ($count &gt; 0 &amp;&amp; $count &lt; 4 ) { printf('&lt;li class="large"&gt...
Retrieve IDs from custom field, count and display results differently according to count
wordpress
I am working on a wp-ecommerce enabled site and am trying to change the display order of the products on the product grid page. Any help would be greatly appreciated.
In the WordPress backend select Settings | Store . Select the Presentation tab. Scroll down to the Product Page Settings section and change the value of the Sort Product By dropdown to: Drag &amp; Drop Now you are able to click on a product in Products | Products , hold it and drag it to the position in which you want ...
how to change displaying order of products in wp ecommerce
wordpress
I have a call to add_image_size like so: <code> if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } if ( function_exists( 'add_image_size' ) ) { add_image_size( 'sidebar_thumb', 109, 60 ); } </code> But then when I try to use that image size in my template... <code> if ( has_post_t...
Your not specifying a $crop value so your images are being cropped using a soft proportional crop. Set crop to TRUE for a hard crop. <code> add_image_size( 'sidebar_thumb', 46, 60, TRUE); </code> *no need to call function_exists for add_theme_support or add_image_size unless you want to be backwards compatible to pre 2...
A little confused as to what add image size actually does
wordpress
Here's the situation- I've customized the comment submission whereby users can provide a rating, and this gets stored as a meta value in the commentmeta table. I can query to return the average value and display in the post. No problem so far. What I want to do now is sort posts by this average rating. My code to get t...
I've done exactly something similar. First, use <code> get_comment_meta </code> for getting the per comment rating, you don't need the SQL for it. Then get the average rating (addition of individual comment ratings on a single post / number of comments on this post). Then store this average value as post meta for this ...
How to sort posts by the average of comment meta values
wordpress
I want to wrap some html (divs and classes) around the tag (to create the appearance of photo corners by way of an image sprite). Basically, I want to re-write all tags added by WP in the content by way of some code in my functions file from this: <code> &lt;a href="#link"&gt;&lt;img src="image.jpg" class="someclass"&g...
One way is to do this dynamically: <code> function do_the_replacements($matches){ // $matches[0] = full string // $matches[1] = link attributes // $matches[2] = link contentes (the image) // change 'someclass' here... if(strpos($matches[2], 'someclass') !== false){ return ' &lt;div class="featured-img"&gt; &lt;a '.$mat...
Change Output for Images in Content
wordpress
I am developing a site on MAMP and everything is going fine except that I thought I would check how all the default archive pages look. I typed 2011 at the end of the base url and it retrieved a yearly archive as expected. The problem is that the font sizes of every element change to a smaller size. I understand that t...
Use your browser’s debugger to find the applied CSS rules. Usually there are some some unclosed elements and/or some badly written CSS rules like <code> #content * { font-size: .9em } </code> . It’s not a WordPress problem. :)
All font sizes change when manually typing 2011 into url and going to archive page
wordpress
I'm having a bit of trouble getting a custom post type query working coming from two drop downs. Let me show you what I'm using: The Form: <code> &lt;?php require($_SERVER['DOCUMENT_ROOT'] . '/wp-load.php'); ?&gt; &lt;form method="post" id="searchform" action="http://www.findabuilder247.com/directory"&gt; &lt;?php $arg...
You seem to be using 2 separate queries there, the first (query_posts) won't do anything, and the second is the query that will be used. Have you tried: <code> $args=array( 'category__in' =&gt; $cats, 'post_type' =&gt; 'profiles', 'posts_per_page' =&gt; 10, 'order'=&gt; 'ASC', 'orderby' =&gt; 'title' ); $loop= null; $l...
Custom Post Type Query W/Category Dropdown
wordpress
I want to give errors like this, while activating my plugin. Which hooks should i use ? Can you share simple examples ? In shortly,when user activate my plugin, is a directory's CHMOD isn't 777 , i'll warn it and stop activation.
Check out : WP Error And this link covers how the plugin activation error works: http://www.squarepenguin.com/wordpress/?p=6 And I don't see any reason why you should ever chmod a directory to 777
Showing Notifications While Activating Plugin
wordpress
I have a site using Advanced Custom Fields to create and store various bits of relevant info. These need to be included in the main general search, which by default only searches the title and main content. I've found plenty of info about getting search results based on specific bits of postmeta, but I have an issue wi...
If your up for using a plugin, Relevanssi - A Better Search might be worth trying out. The standard (free) version supports searching post meta.
How to make search include data from wp_postmeta?
wordpress
I am working on a theme that has a custom post type called <code> Languages </code> and it will have a custom taxonomy called <code> Language </code> which will act as a category. Now let's assume my <code> Language </code> taxonomy has these 4 values for now, <code> English </code> , <code> French </code> , <code> Ger...
This code runs a foreach loop through each value associated with the language taxonomy then runs a query on that value to get the posts associated with it. <code> $taxonomies = get_categories( array( 'taxonomy' =&gt; 'language' ) ); foreach ( $taxonomies as $tax ) { global $post; $args = array( 'language' =&gt; $tax-&g...
Show 10 newest post for each value of a custom taxonomy
wordpress
I have two pages on my Wordpress site: <code> mysite.com/?p=100 mysite.com/?p=200 </code> I think I should be able to hook into Wordpress' actions somewhere and re-query the post, so that content for <code> mysite.com/?p=200 </code> would be displayed on the page <code> mysite.com/?p=100 </code> Based on feedback from ...
<code> pre_get_posts </code> hook should work for this: <code> add_action( 'pre_get_posts', 'wpse35832_pre_get_posts' ); function wpse35832_pre_get_posts( $wp ){ if( $wp-&gt;query_vars['p'] == 200 ): $wp-&gt;query_vars['p'] = 100; endif; return $wp; } </code> It may work a bit differently if pretty permalinks are used,...
How can I override one post and make it display content for another post?
wordpress
No matter what I do - I can't get the hard cropping mode in the_post_thumbnail to work. Here's what I have: <code> add_image_size( 'Blog', 300, 300, true ); the_post_thumbnail('Blog'); </code> I've also tried: <code> set_post_thumbnail_size( 300, 300, true ); the_post_thumbnail(); </code> I've tried uploading new image...
I've actually finally fixed this issue. It seems that the hard-cropping works if you set the image size inside a function that is hooked into the "after_setup_theme" hook. So, the below would work: <code> function add_custom_sizes() { add_image_size( 'portfolio-thumb', 243, 163, true ); add_image_size( 'portfolio-image...
the_post_thumbnail hard cropping not working no matter what
wordpress
i need a little help to with this issue: I have a string wich contains shortcodes like <code> [shortcode data="1" data2="2"] </code> How I can extract with regex? without wordpress system? Thanks in advance.
Where is this string located ? I know you wrote "without wordpress system" , but WordPress has a function get shortcode regex If you really want to avoid it for some reason, the following example might help you : <code> // check the post for a short code function check_shortcode( $shortcode = NULL ) { $post_to_check = ...
extract shortcodes from string
wordpress
So when looking at the html-view in the editor there is no <code> &lt;p&gt; </code> tags, when a view the post every line break is surrounded with a <code> &lt;p&gt; </code> . How?
The content is run through the wpautop filter (there's a lot about that on Google).
How does Wordpress insert Paragraphs in posts
wordpress
I have a lot of themes in my test wordpress site. I get a little frustrated that I can't show more than 15 at a time. In pages and posts you can click "screen options" to choose the number, but it looks like "Themes" has no such option. Is there another way to increase the number?
It's hardcoded into the <code> WP_Themes_List_Table </code> class that's responsible on Line 50. <code> $per_page = 15; </code> So in short, you can't without modifying a core file. Link to source .
How can I show more than 15 themes at a time in the admin menu?
wordpress
I'm looking a way to avoid regular users go to profile and dashboard page. Have this little code to work with profile page: <code> function lockdown_profile() { global $current_user; return !current_user_can( 'manage_options' ) ? wp_redirect("/profile") : true; } add_action('show_user_profile', "lockdown_profile"); </c...
<code> show_user_profile </code> is the wrong hook to use. You should redirect before anything gets sent to the browser (eg. before headers are sent). Fortunately there are actions that happen much earlier: <code> load-{$pagename} </code> is the one you want. So you can hook into <code> load-index.php </code> and <code...
hook for dashboard show_user_profile
wordpress
I need to do a simple post query that will get any post that has at least one tag. This is my current code that gets the posts with tag ID 27 or 36, but I need to modify it to get all posts with at least one tag. <code> $args = array( 'numberposts' =&gt; 5, 'tag__in' =&gt; array(27,36) ); $myposts = get_posts( $args );...
You could try this. <code> $all_tags = get_tags(); $tag_id = array(); foreach( $all_tags as $tag ) { $tag_id[] = $tag-&gt;term_id; } $args = array( 'numberposts' =&gt; 5, 'tag__in' =&gt; $tag_id ); $myposts = get_posts( $args ); </code>
How to query with get_posts() for posts with any tag
wordpress
I recently migrated a WordPress install from a subdirectory to the root. After the migration everything worked great, except that I can no longer set a featured thumbnail or add a picture in the WYSIWYG. On a possibly related note, I can only set post tags from the Quick Edit screen and not the post edit screen. When I...
I figured it out. It was a jQuery conflict. I deregistered the default jQuery in WordPress to use the Google CDN version. Works great on the front-end, but it was messing up the admin. Wrapped it in an !is_admin() if statement and all is well.
Images will not attach to posts after site migration
wordpress
I would like to get the ID (or permalink) of the page the visitor visited just before visiting the current page - in other words the ID of the last page in the browser history. Can this be done? Any idea how to do it?
Break this down into two parts: First, we create a variable that stores that last-visited page URL, like this: <code> $prev_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; </code> Then, you could either use substr and strpos to trim down everything between ?= and the / after the ID number. like t...
Get previously visited page ID
wordpress
When I Insert media into my post or page it's rendered as a normal link. Would it be possible to somehow theme links that point to e.g. PDF or other file types?
I think the easiest way would be doing this with jQuery: http://jsfiddle.net/pFyPz/
Theming media inserts
wordpress
Under what circumstances would you, (should you?) use a foreach loop, instead of the wordpress loop. I have no real coding need, but I'm curious. What's good practice here? Should I: <code> $args=array( 'post_parent' =&gt; $pos_id, ); $sublabels=get_posts($args); foreach($sublabels as $sublabel) { // blabla something t...
Your examples are showing two different thing The first one is looping over categories and the second is looping over posts, so the answer in this case is simple and depends on what you need to loop over (posts or categories). No if you meant when should you use <code> query_posts() </code> vs. <code> get_posts() </cod...
When to use Wordpress loop or Foreach loop?
wordpress
I recently asked a question on how to get all images from all posts - and I got a working answer, but unfortunately the code gets post-thumnbnails as well, and I didn't find a way to limit the number of queried images. stackexchange-url ("My last question is here.") Thanks. <code> &lt;?php $query = new WP_Query( array(...
Try this: <code> $image_count = 0; $max_images = 10; //set this to the max number of images you want. $ids = get_posts( array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; -1 ,'fields' =&gt;'ids') ); if (count($ids) &gt; 0){ foreach ($ids as $id){ while ($image_count &lt; $max_images){ $args = array( 'post_type' =&...
Get all images from posts with maximum number and without featured image
wordpress
I'm having a difficult time writing out the PHP for this magazine layout I'm making. Here's the prototype: http://socalnpo.org Here's what I currently have: http://socalnpo.org/wp The first 3 are the most recent (left to right) and the next 6 are the older ones. They all go in reverse chronological order. I'm not sure ...
There is no reason to need 2 loops or to alter the query in any way if your are just showing the 9 most recent posts. You can use a loop counter to create the extra divs you need. <code> &lt;div id="featured"&gt; &lt;?php $count = 0; if (have_posts()) : while (have_posts()) : the_post(); $count++; if ( $count &lt; 4 ) ...
WP_Query and help with the loop for magazine front page
wordpress
I would am using the code below so that on my wordpress site if <code> ?logout </code> is appended to the end of the URL the user will be logged out. This works well - if the user visits a page such as <code> mysite.com/?logout </code> or <code> mysite.com/test-page/?logout </code> or any page where the <code> $_GET['l...
This should do it: <code> add_action('plugins_loaded', function(){ wp_set_current_user(0); },0); </code>
How can I log a user out of Wordpress before the page loads?
wordpress
Is there a way to completely remove (unset) the left hand side admin menu? I examined the ozh-admin-drop-down-menu plugin, since it removes the entire admin menu and adds a top menu bar in order to get a clue.. I made a few snippets, but probably I am missing sth.. I couldn't manage to find a way out..
Just to explain the solution better: I made below additions to theme's function.php in order to remove visually (hide) left hand admin menu: <code> add_action('admin_init', 'add_custom_admin_style'); function add_custom_admin_style(){ wp_register_style('custom_admin_style', content_url('themes').'/custom_admin.css'); w...
How to unset adminmenu completely?
wordpress
I need to embed the last posted video (from a specific category) to the frontpage of my Wordpress site. Is there any shortcode (or widget, even) I can use to simply filter my posts by category, and have the content (in this case, an embedded .wmv or .m4v) displayed based on a "last posted" basis. I am currently able to...
This should work, even outside of the loop: <code> $latestPost = get_posts('numberposts=1&amp;category=YOUR_CATEGORY_ID'); </code> The Wordpress function <code> get_posts </code> sorts by post date, newest-to-oldest by default, so you'd get the newest post in whatever category you choose. Also, even though you are only...
Wordpress: embedding last posted video
wordpress
I'm trying to create a simple function to do a "status test". Goal is to test and see if the current page being viewed has any child pages or not. Using this to alter layout to accomodate child pages. The following code seems like it should work, but alas, no dice. Anyone see what I'm missing? <code> function is_subpag...
Your above function tests whether a page is a child page of some other page, not whether it has children. You can test for children of the current page like so: <code> function has_children() { global $post; $children = get_pages( array( 'child_of' =&gt; $post-&gt;ID ) ); if( count( $children ) == 0 ) { return false; }...
Function to return true if current page has child pages
wordpress
I'm attempting to move toward developing WordPress sites locally, rather than on a live server, and as part of that move I'd like the ability to have a local and a remote version of a site, and easily deploy changes made locally the the remote site. That's easy enough for the filesystem changes using something like Git...
Well, I think you've already alluded to the answer. You need to script your database changes. And then run that script on the live database using phpMyAdmin or something like this command if you have terminal access: <code> mysql db_name &lt; scripted_changes.sql </code> If, however, you've referring to CONTENT changes...
How can I (semi) automate a database export and import to a different location?
wordpress
I have a developer who is accessing the wp-config file directly to get database information. I would think that WP has a better way to do this. What do you think community?
I am not aware of a Wordpress function to do this. But have a look at this search and replace tool: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ This achieves what you want by reading in the wp-config file and scanning through it. Have a look at the function "icit_srdb_define_find" on line ...
Best function/method to access wp-config?
wordpress
I have a custom query that I created to display the team members of a company, but my client has asked whether they can have control over the order in which each team member is displayed. Is this possible? At the moment, the default display is to order by date, but it would be great if you could actually control the or...
You could order your custom post type with a custom field such as 'order' that your client could change for each post : <code> $teamFeed = new WP_Query( array( 'meta_key' =&gt; 'order', 'orderby' =&gt; 'meta_value' ) ) </code> Theres also a plugin to order custom post types with drag and drop functionality, but I never...
Allow admin to determine the order of queries?
wordpress
How i can add "Post Options" section under wysiwyg editor? Like this
You must use <code> add_meta_box </code> function. Take a look to this tutorials: Using add_meta_box() Tutorial: Creating Custom Write Panels in WordPress Example How To Add Meta Boxes To Edit Area
Add "Post Options" for new wordpress post
wordpress
I use a lightbox to display images from posts in a website that is updated by differents authors. Or course, the lightbox only works if the author makes sure that he uses link to the image directly while uploading the file. 1/3 of the time, the author forgets and the lightbox shows the html of the attachment.php page. ...
Answer is this (thanks to Wordpress Vampire here : stackexchange-url ("Change Attachment Post URLs to File URLs")) : Create an attachment template file within the theme. Since we are only interested in images, the file should be image.php <code> &lt;?php if ( have_posts() ) { the_post(); $image_url = wp_get_attachment_...
i want attachment.php to return the image
wordpress
I'm trying to do some filtering for some posts in <code> WP_Query </code> , but I can't seem to get the right condition. Basically what I wanna do, is get posts that have the custom field <code> event_data </code> (sorted by this field) and among those posts to select only those who have one of these other fields fille...
Sorry, doesn't work that way. The "simple" meta parameters are converted into part of the meta_query as a whole. So it's not a separate thing, and your OR relation applies to it as well. Your query thus is not possible with the normal query system, because you want to mix ANDs with ORs (you want items that have event_d...
Meta Query with AND & OR?
wordpress
trying to make a custom column sortable in the media library. Found lots of examples for posts, and users but can't get them to work on the media library page. <code> function wpse_hook_isv_columns() { add_action('manage_media_custom_column', 'isv_custom_media_column_content',10,2); add_filter('manage_media_columns', '...
You cannot do a sort on the attachment meta data specifically because it's stored in a serialized string. Whilst <code> WP_Query </code> can sort on meta values it can't sort on data that's serialized. For example <code> wp_get_attachment_metadata </code> fetches and unserializes that for you inside the column callback...
sortable custom column in media library
wordpress
I am using <code> $wpdb-&gt;flush(); </code> at the base of my page in an attempt to prevent the query executing multiple times due to caching however it seems that it isn't flushing the most recent query but the entire cache as my page is not loading past generating my content. Possibly Relevant information: I am usin...
In the code you posted in your other question, your call to flush() is using the wrong variable: $wpdp-> flush();. Since this is an undefined variable, it's likely that you're simply getting a PHP runtime error at this point, stopping page execution.
$wpdb-> flush(); breaks the loop
wordpress
I'm displaying a group of thumbnails on a Wordpress site using the Magic Fields plugin Here's the code in my template: <code> &lt;?php $client_images = get_group ('images'); foreach($client_images as $image){ ?&gt; &lt;div class="thumb"&gt; &lt;a href="&lt;?php echo $image['client_image'][2]['original']; ?&gt;"&gt; &lt...
I have worked many times with timthumb, but I do not know magic fields, and I am sorry, but i fail to understand a few things : you want to put a FULL resolution inside a tooltip ? does thispart of your code <code> $image['client_image'][2]['original']; </code> from above works ? if it does, there is no reason it shoul...
Get dimensions of referenced image (Magic Fields fields plugin with phpThumb)
wordpress
I have two types of files in my WordPress Media Library, one is for pictures and attachments from posts, the other is for attachments from a custom post type. I want to organize them separately, use my plugin's dir as basedir for the custom post type, while keep other files in Wordpress' default upload directory. Is it...
The following code will change the upload directory for a specific post-type! Just be sure to swap out both instances of "post-type" (line 14) with the name of your custom post-type. <code> /** * Change Upload Directory for Custom Post-Type * * This will change the upload directory for a custom post-type. Attachments w...
How to add more upload directories?
wordpress
I've been testing the new 3.3 RC1 code against my plugin and I've found a significant difference in the switch_theme() function that foobars my ability to preset widgets dynamically. The problem appears to be the call to the global $sidebars_widgets. Notice that in prior versions, the switch_theme() method did not invo...
Likely your code is somehow breaking on the new widget handling methods, which save old widget layouts when theme switches occur. http://wordpress.org/news/2011/11/wherefore-art-thou-widgets/ Most likely, you'll have to switch themes before adjusting the widgets in it, since widgets don't survive theme switches anymore...
WP 3.3 RC1 new switch_theme() method foobars sidebars
wordpress
I have enabled custom php in my pages through the use of the <code> exec-php </code> plugin so I can run more complex pages than the standard WordPress page. I have had no problems with this plugin so far. I have recently moved a page I was using independently from WordPress to inside the WordPress system. Now instead ...
Using a plugin to run PHP code inside your content is not the sanest thing to do, especially when said code is not idempotent . Basically, you cannot guarantee that your code will only run once per page load, since several different things in the system may be processing your content, and thus executing your code, mult...
MySQL query performed 4 times inside loop
wordpress
I'm using Cimy User Extra Fields to add more registration fields. I'm also using Contact Form 7 Dynamic Text Extension to pre-populate contact form fields. I've read, in order to be able to use Cimy fields to pre-populate the contact form i need to add a shortcode. I've read this here . He say's that you have to add a ...
So you're just looking for a simple shortcode that will call an existing function? The following will create the shortcode you're looking for, but admittedly I haven't tested it with the Cimy User Extra Fields plugin. Add this to <code> functions.php </code> and try it out: <code> function shortcode_cimyFieldValue( $at...
How to add a shortcode to call a function
wordpress
I am creating a plugin that creates a new custom post type. How can I check if the custom post type has been created already (maybe by the user in functions.php for some other use)? Actually I would like to know what is the best way to go about it, maybe add a prefix to my custom post type to make it as unique as possi...
To check for the existence of a post type, use <code> post_type_exists </code> . For instance like this: <code> if ( ! post_type_exists( 'yourpt' ) { $args = array( // your new post type's arguments ); register_post_type( 'yourpt', $args ) } </code> As for the prefix, that's a matter of personal taste and how common yo...
Check if a custom post type has already been created
wordpress
I read the others on the site and i didnt find a working solution. I am using the 20-11 theme and i tried using <code> &lt;--more--&gt; </code> (in visual and html) with no luck, using excerpts and whatever i could find. Nothing work I am viewing the page from the root/homepage. How do i make the read more link with ju...
try using <code> &lt;!--more--&gt; </code> or try the 4th button from the right in the visual editor; or try the 'more' button in the html editor. I am viewing the page does that mean you are trying to get a 'read-more' in a static page?
How do i set the read more link?
wordpress
I'm getting this message on a WP 3.2.1 install with PHP version 5.2.17 <code> Notice: Undefined index: filter in /home/netstewp/public_html/wp-includes/default-widgets.php on line 382 </code> Any idea why?
That a Notice, not an error. Turn off notices in your PHP installation, or turn off the WP_DEBUG mode. More importantly, turn off display_errors. The display_errors setting should never, ever, be enabled on a production site. That's for debugging only.
Notice: Undefined index: filter in ...wp-includes/default-widgets.php on line 382
wordpress
I'm trying to add an avatar option for my blog and would like to avoid using Gravatar or custom avatars so I wish to use Facebook profile pic instead of an avatar. I know that there are plugins for that but they're all a bit cumbersome. I tried Incarnate but the issue with it is that there is no authentication so anyon...
To sum up, I'd like a plugin or a code so that visitors to my blog are automatically represented with their FB profile pic (if they are already logged in to Facebook) without the need for them to register or log in with FB details to my blog. There is no possible way to do this. You cannot get somebody's Facebook infor...
Facebook profile pic used as avatar
wordpress
I'm looking for a best practice/ideas for modifying the status/data of a page after an event. Here's an example of what I'm trying to accomplish - This WordPress site would allow users to sponsor people (just one sponsor per person). Each person that is eligible for sponsorship has their own page, which is created via ...
What you could do is create a metabox for the 'People' custom post type which would have radio values 'Not Sponsored' and 'Sponsored' (Not Sponsored b default). PayPal posts some transaction details to the notify url you have specified. Once you recieve the proper information from PayPal, like payment status is complet...
Change status of page after an event (Looking for best practice advice)
wordpress
I would like to create a list of all the alphabets that represent each user in my site. Example: <code> A -&gt; Link that shows list of all users whose **nickname** starting with letter "A" B -&gt; ...starting with letter "B" C -&gt; ...starting with letter "C" D -&gt; ...starting with letter "D" E -&gt; ...starting wi...
There's the WP_User_Query for that: <code> /** * List all Users * Use as: Template Tag * * @uses WP_User_Query * @return (array) List of user objects */ wpse35713_get_users_list() { $query = new WP_User_Query( array( 'order' =&gt; 'ASC' ,'orderby' =&gt; 'login' ) ); $users = $query-&gt;get_results(); $html = "&lt;ul&gt...
Users: List A to Z, for Users
wordpress
I'm trying to make a registration form with a registration process like the following. Can it be done? These are the fields for the registration form. <code> Username Email Address First Name Last Name Contact Tel No Company Name Address (room for 3 lines of text) Postcode Industry (drop down list) Product Interests (t...
Ended up not doing this. As mentioned in the other answer Gravity forms may have worked but not sure as i've never used it. I just left the registration as it was and manually change peoples roles.
Custom registration form with different registration process based on what's selected
wordpress
is there a way to bind some extra script to the WPSetAsThumbnail function? the function automatically inserts the image into the post's metabox, but what if i wanted to do something else with it? could i make it alert('bacon') after the thumbnail is set via ajax? i'm trying to get a way to set the thumbnails from the q...
In the end I found that I could not bind or trigger this action. I had to duplicate it as follows with the javascript and then an ajax callback. Javascript: <code> function PrismSetAsThumbnail(id, nonce){ var $link = jQuery('a#wp-post-thumbnail-' + id); $link.text( setPostThumbnailL10n.saving ); jQuery.post(ajaxurl, { ...
Bind to WPSetAsThumbnail
wordpress
Is there a way to use the wordpress theme / plugin editor inside my plugin to give the user the ability to edit the css file of my plugin ? Im building a plugin that gives the user an option to add some CSS. First i was going to use just a textarea but then i thought it would be pretty could if i can use the Wordpress ...
To start with you could use the following code. For security you could also add some nonce check and even use the settings api. Here <code> plugin-test </code> is your plugin folder name. <code> $file = stripslashes('plugin-test/style.css'); $plugin_files = get_plugin_files($file); $file = validate_file_to_edit($file, ...
use Wordpress theme / plugin editor in my plugin
wordpress
The goal is to offer a button/select drop-down or similar to switch the public interface 1) language on the fly. What I'm searching for Plugin or Theme Code... ... or Ideas Using a work-around with <code> load_textdomain() </code> would be appreciated to leave translation to .po/.mo files Ideas on how to parse the stri...
By far the best (easiest) way is to use the locale filter (inside <code> get_locale() </code> ). First set up a quick function for retrieving a different language to use on the <code> locale </code> filter. <code> /** * A function returns with returns the user's selectd locale, if stored. */ function wpse35622_get_new_...
Change language by clicking a button
wordpress
I need help to create a template for an archive with specific a keyword by category sorted by date. This is the code for my archive page so far: http://pastebin.com/WEjNGhJ1 My client wants every navigation menu item to go to an archive page for that particular keyword. Example: "Beauty" navigation location will displa...
Categories will use category.php by default as their archive template (site.com/category/category-name). Customize that with the code you've used here, rather than using a 'page template'. If you don't want it to say category/ in the URL there are plugins or functions.php code you can use to remove it that can be found...
Archive with specific keyword by category sorted by date
wordpress
I've created quite a few custom websites but I've come across this problem with various addons/plugins or just general code. How can I avoid the "headers already sent" error? I've tried to put the code as far up in the header.php file as possible but have never managed to get around the error. Is there an easier way to...
See WordPress codex page - FAQ Troubleshooting
Avoiding "headers already sent" in Wordpress
wordpress
Is there an easy way to plot a location on a Google map using an address specified in a custom field? For example, if a post has the following address specified; 1600 Pennsylvania Avenue, NW Washington, DC 20500 A Google map will automatically be displayed on the page with with a marker on this exact location? Surely i...
Dean, your best bet is to do it through JS on the front end. I use the following function to covert the postcode to a Lat and Lng: <code> function codeAddress(address){ geocoder.geocode({ 'address': address }, function(results, status){ if(status == google.maps.GeocoderStatus.OK){ map.setCenter(results[0].geometry.loca...
Plot location on Google map using full address specified in custom field
wordpress
I have a defined set of seven different post types and would like to display an icon for each one in the search results list. I've got the following code to display the post type but have no idea how to extend it into an if <code> &lt;?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type-&gt;l...
<code> &lt;?php $post_type = get_post_type($post); switch ($post_type) { case "type1": echo "&lt;img src='label1.png'/&gt;"; break; case "type2": echo "&lt;img src='label2.png'/&gt;"; break; } ?&gt; </code>
Display an icon based on post type
wordpress
I am looking to display <code> x </code> (undecided) number of recent posts (no more than 10) on my home page. For each post, I would like to display the title and a snippet of the content. I can whip up a SQL query myself to get this but I was wondering what the WordPress function is to get this. The closest I have go...
<code> &lt;div id="posts"&gt; &lt;?php // define query arguments $args = array( 'posts_per_page' =&gt; 8, // your 'x' goes here 'nopaging' = true // possibly more arguments here ); // set up new query $tyler_query = new WP_Query( $args ); // loop through found posts while ( $tyler_query-&gt;have_posts() ) : $tyler_quer...
How to display recent posts on home page with custom HTML
wordpress
I'm following this tutorial by Justin Tadlock on creating meta boxes. http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/ I can get a meta box with a single field to work without problem but I would like to create a meta box with several fields. For example a meta box called "Staff Detail...
This is what you are looking for. <code> /* Define the custom box */ // WP 3.0+ add_action( 'add_meta_boxes', 'staff_details_metabox' ); // backwards compatible add_action( 'admin_init', 'staff_details_metabox', 1 ); /* Do something with the data entered */ add_action( 'save_post', 'save_staff_details' ); /** * Adds a ...
More than one meta field in a single meta box?
wordpress
Maybe I'm doing this the long way but I need to make something like this: <code> &lt;?php echo do_shortcode('[mu-events months="11" startmonth="today" orderby="time" orderas="ASC" sites="?&gt; &lt;?php get_current_site();?&gt; &lt;?php"]'); ?&gt; &lt;?php echo do_shortcode('[mu-events months="11" startmonth="today" ord...
You could do it in this way. <code> echo do_shortcode('[mu-events months="11" startmonth="today" orderby="time" orderas="ASC" sites="' . get_current_site() . '"]'); </code>
How can I call a PHP function inside a hardcoded shortcode?
wordpress
I cannot figure this out. There seems to be no checkbox or anything similar in function to add the newly created custom post type archive page into the menu. Also the link must be active, if you are on the page. This probably isn't possible, but is there some plugin for it? For the love of me, I cannot find it :( I onl...
This is one method that I think should work (though it's not tested). <code> //Hook on to the filter for the (custom) main menu // 'wp_list_pages' filter is a fallback, when a custom menu isn't being used add_filter( 'wp_list_pages', 'new_nav_menu_items' ); add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' ); //Can...
How to add custom post type archive page links to nav menu?
wordpress
I'm trying to a build a system for a client that involves two posts types: "Clients" and "Media Placements." I need a way to associate Media Placements with a particular Client (essentially treating Clients like a category while retaining full post functionality). Each client needs to have many media placements associa...
There is a neat plugin that might be of use for your task: Posts 2 Post It is capable of establishing relationships between posts and post-types.
Associating two custom post types
wordpress
When Twenty Eleven theme is activated, it inserts several default widgets into its sidebars. How can I code my theme to do the same?
Johannes Pille is right TwentyEleven's widgets such as Archives and Meta are hardcoded into their sidebar.php Here is what I would do: First define your sidebars in your functions.php like so: <code> if ( function_exists('register_sidebars') ) register_sidebar(array( 'name'=&gt;'Left Sidebar', 'before_title' =&gt; '&lt...
How can I insert default widgets when my theme is activated (similar to what twenty eleven does)?
wordpress
Custom walkers seem to be a poorly-documented area of WP. Online tutorials focus on styling the output, not on directing the walker to go where you want it. I am reading the code, but I wonder if there's a good resource I'm missing. If you know about walkers, how and where did you learn about them?
I stumbled across this article , I think it could be of tremendous use to you. It helped me understand it a lot better. I believe there was a question on here in which (I think) @Rarst answered that linked to it, but I can't seem to find it. If someone can find it and edit my answer in place of this that would be great...
What is a good resource to find out about making custom walkers?
wordpress
I'm having custom field "prime" with values yes or no. I want to get the post id's with selected value " Yes ".How can i get that. Thanks in advance
Try something like this <code> $posts = get_posts( array( 'numberposts' =&gt; -1, 'meta_key' =&gt; 'prime', 'meta_value' =&gt; 'yes' ) ); $post_ids = array(); if ( $posts ) { foreach ( $posts as $post ) { // Push post's IDs into array array_push( $post_ids, $post-&gt;ID ); } } </code> code isn't tested but it should wo...
get post id using custom filed value
wordpress
I was wondering if the default image generated for a user in the comment section is "set" somewhere in the WordPress backend. If so, I'm not sure where this setting is. Please see this image to see what i'm referring to: The user Jimmy Jacob doesn't have an image yet the commentor Catherine does. Without installing plu...
Here's a function you can put in your theme's functions.php file to force your own default avatar. Update the $myavatar line to point to your image path/name: <code> // Adds a new default avatar to the list in WordPress admin add_filter( 'avatar_defaults', 'mytheme_addgravatar' ); function mytheme_addgravatar( $avatar_...
Alter the image used for a user who has not uploaded a custom image yet
wordpress
I want to be able to add more fields to the comment form including a date field and a multiple image upload field. I have found a few links showing how it might be possible to add more text fields but how would i allow uploading of multiple photos? When using this contact form the user will be logged in. Ideally I woul...
I can explain to you here how to do it , but it is quite long , it evolves many functions,and a long code (even if simple with the new comments form functions and hooks). so the best is just get a plugin that will simplify all. Try this one . , or search others on the same repository . edit : this might be more suitabl...
adding more fields to the comments form including image upload
wordpress
I am using the Extended Gravatar plugin by Reza Moallemi and it works great. However, on my about page I have a large gravatar to show the author. I would like to know if there is a class I can add to not show the hovercard. Or php that can be added to get_avatar('$email') I could just not include the plugin on the abo...
Since @toscho has seemed to have revived this question here is one way to do it (not saying it's the best but it works) It's important to note I've switched to Jetpack which has hovercards built in. If you are using Jetpack here's how you do it. <code> function nifty_remove_grofiles() { if(is_page('about')){ remove_act...
Remove hovercard for only certian gravatars
wordpress
I'm having a hard time figuring this one out. I'm running a simple users query : <code> $args = array( 'role' =&gt; 'custom_role', 'orderby' =&gt; 'ID', 'order' =&gt; 'DESC', 'number' =&gt; 3 ); $users = get_users( $args ); </code> And the resulting array has duplicate entries : <code> Array ( [0] =&gt; stdClass Object...
Seems like a silly question, but are there exactly 2 users in the database? Or are there more. The only thing I can see happening is because you are setting to 3, it's looping back through. Another thing to try is checking the peterpanpan user, to see if he has the custom_role twice in his user_meta.
Why does get_users suddenly return duplicates?
wordpress
I want to modify WordPress so that it requests content from a function if content is not found in the database. I want to edit the section of the code which requests and returns the post content from the database so that: if it does not find the content in the database, it calls and gets the content from my function, i...
Possibly the place to do this would be in the 404.php file of your theme. If there isn't one, create one and Wordpress will pick up. Note: if you want to return "non-404" content from this file you will probably need to clear the headers and set the status to 200. I've done something very similar on other systems and i...
Load posts from external source if not found in database
wordpress
I'm trying to figure out why the_tags(); when used in the loop are only showing when I'm logged in to the site. I've never come across an issue like this before when developing themes. my code is now on pastebin: http://pastebin.com/cSJy5kyH As I said, the tags appear when logged in but only then. Am I missing a permis...
The code you posted work just fine , logged in or not . I have confirmed it on my server in multiple locations. There is something else in your theme that is causing it . do you have any other conditional tags there ? like <code> is_admin() </code> <code> is_user_logged_in() </code> or any other ?? Any plugin you insta...
the_tags only showing when logged in?
wordpress
I'm currently having some difficulties showing a featured image for the first post only. Currently the image only shows if the post is the only post or if the post is a sticky post. (I realize this isn't the preferred code for displaying a featured image, but it was the only code I could come up with having a html5 tem...
You can use <code> the_post_thumbnail() </code> to output the thumbnail image directly. <code> &lt;?php $count = 1; ?&gt; &lt;?php while (have_posts()){ the_post(); ?&gt; &lt;article id="&lt;?php echo $post-&gt;post_name; ?&gt;" class="post&lt;?php post_class(); ?&gt;" itemscope itemtype="http://schema.org/Article"&gt;...
Featured image for first post only
wordpress
I've been trying to get an email notification to fire when a new custom post type (in this case, "event"), is published. I've tried a few things and settled down to this simple example that, I imagine, should work just fine. <code> function admin_event_notification() { $message = "Test"; wp_mail( 'jonathan@sabramedia.c...
<code> 'new_event' </code> is not a default wordpress hook. Hence the above will only work if you include <code> do_action( 'new_event' ); </code> in your custom post type's saving/publishing function. Your usage of <code> wp_mail </code> is otherwise correct. See the codex on <code> do_action </code> for reference.
Email notification via WP_Mail on published custom post type
wordpress
I am trying to pass a variable from a URL to PHP using mod_rewrite while maintaining standard WordPress functionality. Here's my mod_rewrite rules: <code> RewriteEngine On RewriteBase / RewriteRule ^(\w+)/$ /index.php?state=$1 [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_...
Ok, I ended up figuring this out. Like I thought, the problem had nothing to do with mod_rewrite and everything to do with WordPress. To solve the issue, I had to use the following code: <code> if(isset($_GET['state'])) { $url = explode("/", $_SERVER['REQUEST_URI']); $url = end($url); $_SERVER['REQUEST_URI'] = "/" . $u...
Why is home page content not displaying with this rewrite rule?
wordpress
Using a pre_get_posts filter to search a given string on all meta_values: <code> $query-&gt;set('meta_value', 'first string'); </code> debug: <code> AND ( (CAST(wp_postmeta.meta_value AS CHAR) = 'first string') ) </code> Works Ok :) but how can I search on all meta_values for an array of strings? For example. I need so...
Yes, I got it: <code> function custom_search_where( $where = '' ) { global $wpdb; if ( is_search() ) { if ( isset($_GET['my-terms']) ) { $count = count($_GET['my-terms']); if ( $count &gt; 0 ) { foreach ( $_GET['my-terms'] as $term ) { // http://codex.wordpress.org/Class_Reference/wpdb $title = $wpdb-&gt;prefix . "post...
Using a pre_get_posts filter to search for multiple strings on all meta values
wordpress
While I remain committed to the open source foundation of WordPress, I do prefer to make a living plying my trade as a developer of quality software that fulfils a need of people willing to pay for it. I have developed a plugin for use by mainly business users of WordPress, i.e. cases of people using blogs to market th...
The way I see it you have two options Paid for plugin The idea of charging for the Pro version as you describe is a good one. We use a couple of paid for plugins. They tend to be reasonably priced when compared to the cost of setting up and running a website and work well. It's also nice to know we can customise the pl...
How do I profit from a Plugin?
wordpress
I'm on a fresh install of WP and I just made a couple test posts. However, when I click on the post to view the 'single' page, it shows a 404. Furthermore, from the dashboard, when I go to the edit screen for that post and click on 'view post', I get the 404 page again. Any ideas on what can be wrong?
Seems like you're not the first one having this problem, you might want to check stackexchange-url ("WordPress permalinks Yahoo hosting(no .htaccess allowed) ")
Can't view post, goes to 404 page. Please help
wordpress
When you choose "Preview", which is actually a link, <code> &lt;a class="preview button" href="?p=52&amp;amp;preview=true" id="post-preview" tabindex="4"&gt;Preview&lt;/a&gt; </code> the post is saved and the preview opens in a new window. I'm sure there is a javascript event attached to this button, I'd like to overri...
Here's a way to do it without modifying the core: <code> add_action('admin_footer','preview_same_window'); function preview_same_window(){ ?&gt; &lt;script type="text/javascript"&gt; jQuery(function($){ jQuery('.preview.button').unbind().removeAttr('target'); setTimeout(function(){ jQuery('.preview.button').unbind().re...
How can I make the "Preview Post" button save and preview in the same window?
wordpress
I'd like to display a Google map of places relating to posts (eg, places I've visited). Is there a plugin or method available that will allow me to have a Google map on a page and when creating a post, I can put in an address or lat/long for the post, so that it automatically gets added to the map? I'm thinking of some...
You could use this plugin , although it may only be compatible to 3.2.1. And this plugin may help you out, although it seems a little complicated to implement a map for all the posts. You could also use a custom field for lat/long on each post, and then create markers using wpdb calls, grabbing the post_meta data, and ...
How can I automatically attach posts to a map?
wordpress
For some time I've been using this code snippet adding both custom post types and custom taxonomies to the WP Dashboard Right Now widget: <code> function dashboard_right_now_content_table_end() { $args = array( 'public' =&gt; true, '_builtin' =&gt; false ); $output = 'object'; $operator = 'and'; $post_types = get_post_...
Moved from comment to answer: Inside your taxonomy registration code, <code> '_builtin' =&gt; true </code> shouldn't be set to true, that's specifically for built in taxonomies only(you shouldn't even be setting that arg) and also conflicts with your args array which specifically asks for a false value.
Taxonomies not showing in WP Dashboard Right Now widget
wordpress
I have a custom field called <code> picture </code> . On the media settings page I've set thumbnail size to 100x100. If upload an image called <code> gecko.jpg </code> , Wordpress automatically resizes it and generates <code> gecko-100x100.jpg </code> . I want to use both the thumbnail size and original size, is it pos...
can you explain why do you need custom fields ? (personally i think they are HUGELY over-used.. especially for images ) if there is no specific reason why you need it , you could use the <code> the_post_thumbnail(); </code> function . like so : <code> the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px...
Display thumbnail from custom field
wordpress
Is there a way of putting "Post X of Y" into my sidebar? I think I can only show it when it is a single blog post (something like checking if the content is_single) but I want to be able to see which post I am viewing. Googling "wordpress post x of y" for the last 20 minutes has given me a lot about category x in page ...
<code> class MY_Post_Numbers { private $count = 0; private $posts = array(); public function display_count() { $this-&gt;init(); // prevent unnecessary queries $id = get_the_ID(); echo sprintf( '&lt;div class="post-counter"&gt;Post number&lt;span class="num"&gt;%s&lt;/span&gt;&lt;span class="slash"&gt;/&lt;/span&gt;&lt...
Post X of Y in single.php / sidebar.php
wordpress
In my functions I'm registering multiple metaboxes with custom fields. A single metabox array for instance, looks like this: In functions.php <code> $meta_boxes[] = array( 'id' =&gt; 'general_info', 'title' =&gt; 'General Information', 'pages' =&gt; array('post', 'page', 'link'), // multiple post types, accept custom p...
Use <code> get_post_custom </code> , it will return an array of all the posts meta info. http://codex.wordpress.org/Function_Reference/get_post_custom
Get fields from metabox array
wordpress