title: Struggling with add_rewrite_rule

text: I've read this: Wordpress redirection to get url friendly That led me to this: 1) wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-the-basics/ 2) wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-post-types- taxonomies/ and per the end of #1, I installed this: wordpress.org/extend/plugins/monkeyman-rewrite-analyzer/ With the plugin I can see and test the rule I added via add_rewrite_rule. However, when I try the same URL request on the front end site I get a 404. I'm struggling to sort out why the rule isn't being applied. p.s. Sorry about the links not being links but my rep from StackOverFlow doesn't seem to carry over to wp.SE


title: Link listings with image

text: So I'm really new to Wordpress and I'm trying to create a simple widget. I want the widget to list the logos of my site's affiliates (similar to the "check out our shows" section on http://www.howstuffworks.com/). I also want it to be easy for the administrators to add/remove images from the list of partners. In other words, I don't want to have to modify the widget's code in order to change the partners. At a very high level what are the steps that I might follow to build this widget?


title: Displaying the last page of posts

text: I'm using a custom loop to display posts using pagination. My query shows 4 posts per page, and there are 4 pages, so 16 posts in total. Is it possible to load in the last page of posts first? So when I load the query, it first shows page 4, then when I click 'show next' it shows page 3, et cetera?


title: How to manage a big collection of files with wordpress?

text: I have a collection of nearly 3000 swf files that will be used in some of WP's post. Two options that I can think of--   1. Upload them to WP Media Library,they'll become attachments, I can query attachment to get them.    2. FTP to host, create database table, query them directly. Which way would you recommend?


title: How to get Facebook to see YouTube/Blip embeds when sharing a link?

text: I run a sketch comedy channel that posts new content regularly. On our site (powered by WordPress.org) we embed Blip.tv players. The problem is, whenever we share a link on Facebook to one of our video pages on our site, it doesn't recognize that there's a video on the page at all. It just loads the featured image of the post. I'd like viewers to be able to watch our videos from their walls - anyone got an answer? In case you're not sure what I'm talking about, here's a link to one of our video pages so you can test on FB for yourself: http://www.juliansmith.tv/2009/11/malk/


title: Using spellchecker plugin in TinyMCE

text: I have installed PSpell and updated the config file to use it instead of GoogleSpell. Then in my functions file I have added spellchecker to the plugins part and the button. The button shows up but it doesn't work. After looking at the source code I see that spellchecker is not included in the TinyMCE init.               function customize_tinymce($in) {     $in['remove_linebreaks'] = false;     $in['gecko_spellcheck'] = false;     $in['keep_styles'] = true;     $in['accessibility_focus'] = true;     $in['tabfocus_elements'] = 'major-publishing-actions';     $in['media_strict'] = false;     $in['paste_remove_styles'] = false;     $in['paste_remove_spans'] = false;     $in['paste_strip_class_attributes'] = 'none';     $in['paste_text_use_dialog'] = true;     $in['wpeditimage_disable_captions'] = true;     $in['plugins'] = 'inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen,spellchecker';     $in['content_css'] = get_template_directory_uri() . "/editor-style.css";     $in['wpautop'] = true;     $in['apply_source_formatting'] = false;     $in['theme_advanced_buttons1'] = 'formatselect,|,bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,pastetext,pasteword,removeformat,spellchecker,|,charmap,|,outdent,indent,|,undo,redo,|,wp_fullscreen';     $in['theme_advanced_buttons2'] = '';     $in['theme_advanced_buttons3'] = '';     $in['theme_advanced_buttons4'] = '';     return $in;     }      Viewing the source I see the plugins being loaded but not spellchecker.               ref : {plugins:"inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen",theme:"advanced",language:"en"}      What am I missing?


title: Woocommerce exclude specific category products from related products

text: I'm trying to exclude products from two specific categories from showing up in the related products on the content single products page. The closest idea I have stumbled upon is this code from http://docs.woothemes.com/document/exclude-a-category-from-the-shop-page/. Any idea how to modify it for related products and NOT for the shop page?               add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );          function custom_pre_get_posts_query( $q ) {          if ( ! $q->is_main_query() ) return;     if ( ! $q->is_post_type_archive() ) return;          if ( ! is_admin() && is_shop() ) {              $q->set( 'tax_query', array(array(             'taxonomy' => 'product_cat',             'field' => 'slug',             'terms' => array( 'knives' ), // Don't display products in the knives category on the shop page             'operator' => 'NOT IN'         )));          }          remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );      }


title: Change default post style to columns

text: I'm trying to format each post that the user uploads. I need the paragraphs to be floated to the left in the first column, and the images to be in a floated left in the second column. (I've tried posting an image, but I need at least 10 reputation) I am new to Wordpress development, so I apologise if this is a silly question.


I'm using $wpdb to connect to a different database than my WordPress one like this:               $newdb = new wpdb(DB_NEW_USER, DB_NEW_PASSWORD, DB_NEW_NAME, DB_NEW_HOST);      I need to insert multiple rows into the database. I used the code from this StackOverflow answer. To run the query, I used the following code:               $newdb->query( $newdb->prepare("$query", $values));      When I did `echo $query`, this's the result: (there are more than 3 columns, but I shortened if for times sake)               INSERT INTO table (column1, column2, column3) VALUES ('%s', '%s', '%s')      When I did `var_dump($values)`, it returned an array with the same amount of strings as I have columns. When I ran the query, I got the following error: > WordPress database error: [Query was empty] I tried selecting from the database in a similar fashion and it did work, so my connection to the db is working. What am I doing wrong?


title: HTML5 Summary tag in editor

text: I'd like to use the summary tag to summarise the content of a post but i'm facing a couple of issues doing that:   1. There isn't an option for it in the wysiwyg - how can i add in elements to the format drop down?   2. Wordpress strips out the element when the editor loads, so saving the page again removes the tag. How can i white list "summary"?


title: Date-Based Conditional Tag

text: I'd like to have a conditional tag that is something like this:               <?php if (is_single()&&is_older_than_october_2011()){do this}; ?>      The part I'm trying to highlight is the is_older_than_october_2011() aspect. There doesn't appear to be any conditional tag that WP offers which has this functunality? Thanks, Brad


title: What is the official way to consume the Wordpress API? (api.wordpress.org)

text: Was wondering if anyone knows here if the API at api.wordpress.org is free to use without keys. I haven't really found any information about key registration. I'd like to use it to make a few requests a day, really not many < 50 requests. What's the official way to go about consuming that API? Thanks!


title: Using AJAX in a plugin to submit form - REALLY confused

text:
Having a bit of trouble using all the Wordpress ajax hooks, and functions. Been reading this post: 5 Tips for Using Ajax in Wordpress But became confused after trying all the code and applying it to an Ajax form. I am calling a function from my plugin class to echo a from on the single posts pages for users to "Swoon" over. The form prints fine. Here's the form code:               //the html form for the front end     function ds_swoons_form(){     global $post, $current_user;     get_currentuserinfo();              $form = '
';         $form .= '
';              $form .= '<form id="entry_swoon_form" name="entry_swoon_form" action="" method="POST">';             $form .= '<input type="hidden" name="ds_postid" value="'.$post->ID.'" />';             $form .= '<input type="hidden" name="ds_userid" value="'.$current_user->ID.'" />';             $form .= '<input type="submit" value="Swoon" class="swoon-submit" />';         $form .= '</form>';          return $form;     }//end ds_swoons_form      My Enqueues:               wp_enqueue_script('json-form');          // embed the javascript file that makes the swoons AJAX request     wp_enqueue_script( 'swoon_ajax_request', plugins_url('ds-swoons/js/swoon-ajax-form.js'), array( 'jquery' ) );          // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)     wp_localize_script( 'swoon_ajax_request', 'SwoonAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );          //add the AJAX action     add_action( 'wp_ajax_swoons_submit_action', array('DS_Swoons','ds_ajax_swoons_form_submit') );      And my javascript:               jQuery('#entry_swoon_form').ajaxForm({     target: '#swoon-response',     dataType: 'html',     data: {            action: 'swoons_submit_action'           },     url: SwoonAjax.ajaxurl,     success : function(responseText) {               jQuery('#swoon-response').html('Swooned!');     }     });      I'm a newbie when it comes to AJAX so I may be way off on this. The article I read was good until I got to the end where it showed a sample ajaxForm request and I got lost. The ajax form function never runs and the page just reloads. SO I am guessing that one of my enqueue functions is not correct. Thanx in advance. EDIT -------------------------------------------------------- New jQuery.post method code - but it still not working               jQuery(document).ready(function(){     jQuery('.swoon-submit').click(function(){         jQuery.post(             // see tip #1 for how we declare global javascript variables             SwoonAjax.ajaxurl,             {                 // here we declare the parameters to send along with the request                 // this means the following action hooks will be fired:                 // wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit                 action : 'swoons_submit_action',                 //nonce for validation                 //swoonNonce : SwoonAjax.swoonNonce,                 // other parameters can be added along with "action"                 postid : SwoonAjax.postid,                 userid : SwoonAjax.userid             },             function( response ) {                 alert( response );             }         );     });     console.log(SwoonAjax.ajaxurl)     });      I do get a really quick error in FireBug but I can't see whats going on quick enough before the request ends. And no error remains after the .post has run. No data is being updated in the DB so I know it is not getting fired. Thanx EDIT 2 ----------------------------------------------------------------- I've gotten the form to submit and it updates the DB using the following code:               jQuery(document).ready(function(){     jQuery('.swoon-submit').click(function(){         var $form = $( 'form#entry_swoon_form' ),             postid = $form.find( 'input[name="ds_postid"]' ).val(),             userid = $form.find( 'input[name="ds_userid"]' ).val();         jQuery.post(             // see tip #1 for how we declare global javascript variables             SwoonAjax.ajaxurl,             {                 // here we declare the parameters to send along with the request                 // this means the following action hooks will be fired:                 // wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit                 action : 'swoons_submit_action',                 //nonce for validation                 //swoonNonce : SwoonAjax.swoonNonce,                 // other parameters can be added along with "action"                 ds_postid: postid,                 ds_userid: userid                  },             function( response ) {                 alert( response );             }         );         return false;     });      However: I cannot seem to get the form field values (hidden) to be sent to the PHP function for DB insertion. The info is in the Firebug console as being sent but no information gets to the PHP function. I think it has something to do with how I am sending the fields to the PHP function but am unsure. Thanx!


title: What is the best way to add an advanced / intermediate / beginner tag to a post

text: Suppose you have a WordPress blog that you are using to produce tutorials, and that you would like to split up your posts according to skill level (i.e. beginner, intermediate, advanced) depending on how technical/difficult/advanced the tutorial is. Furthermore, the blog in questions spans several categories, so using these might be inappropriate. So what's the best way? Using custom field?, tags?, post-type? or even sub- categories? I'm assuming that it shall never be required to retrieve all 'beginner' posts from all categories, though this flexibility would be a bonus.


title: Change or update WordPress loop based on dropdown selection

text: I have a Contact Us page which is showing 9 locations on the sidebar by querying the custom post type "Distributors." I want the user to be able to use a drop down that is populated by the taxonomy "Location." For example, if the user selects "California" from the drop down, it will automatically update the list with just those posts tagged with California. What is the best way to go about this? Also, I don't mind if the page refreshes when the user narrows down to their Country or State. Ideally, I'd like the parent categories to be shown in one drop down, ie. Germany, Japan, USA, etc. Then a second drop down become populated with the children of that category. For example, the first drop down would display USA, then California would show up in the second drop down. Thanks.


title: How to automatically activate users after registration without activation email?

text: I want to auto-login my users after signup without an activation email requirement (I'm not concerned about spammers). How might I go about doing this? Thanks!


title: How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices

text:
Looking to create a customized single.php for my posts. In one column I'd like to display all images added through the add media function (inserted into post). In the next column all other content associated with the post (except images). What I need is the proper / best practice method of doing so. I am just beginning to decipher php but want to do things properly from the VERY beginning. So how can look at the post, pull just the attachment images for display in one column, pull just the textual content (with markup) for another column? Also, when would I consider creating this as a function for functions.php instead of the process residing inside of single.php or any other template file for that manner? Here's what I have so far:
     <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
         <?php         $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );          $attachments = get_posts($args);         if ($attachments) {             foreach ( $attachments as $attachment ) {                 the_attachment_link( $attachment->ID , false );             }         }         ?>

<?php single_post_title(); ?>
         <?php the_content(); ?>
     <?php endwhile; ?>     <?php else : ?>
<?php _e('Sorry, no posts matched your criteria'); ?>
     <?php endif; ?>


title: wpdb->prepare function remove single quote for %s in SQL statment

text: I am using the below wpdb->prepare function in a sql statement. I am passing in several variables some field names and some values. When I try to use the %s for the field name it puts single quotes around it. How can I prevent the single quotes around the field name? The sql statement will not execute with the single quotes? ` $query = $wpdb->prepare("SELECT DISTINCT wp_geo.%s, wp_geo.$field2 FROM wp_geo WHERE wp_geo.$field3=%s",$field1, $typevalue);` Output with single quotes around 'county_short' field name: `SELECT DISTINCT wp_geo.'county_short', wp_geo.county_slug FROM wp_geo WHERE wp_geo.type='trailers'`


title: media resize/crop possibilities?

text: Under admin panel -> media settings there are no minimal width option for thumb or other image modes ex: I would like to crop image widthout distortion -> height 124px and minimum-width 124px and maximum-width 500px So it doesnt allow images to crop below 124px and over 500px but holding always 124px height How to make it happend? some script for functions.php, some plugin?


title: Hook with jquery script is not working in wp-admin

text: This is the hook and script Im using, the jquery script itself is working as you can see in this fiddle:               function my_custom_admin_footer(){                  echo '                       <script type="text/javascript">                          jQuery(document).ready(function($) {                         $(".checkIt").change(function (e) {                             if ($("input:checkbox:checked").length > 1) {                                      alert("Only one attribute is allowed.");                                 $(e.target).prop('checked', false);                             }                         });                     });                 </script>             ';      }          add_action('admin_footer', 'my_custom_admin_footer');      in wp-admin, i get only blank page instead, the problem is definitely in jquery because simple alert script does work:               jQuery(document).ready(function(){         alert("Hello");      });      I don't get it. Although, I'm not pro in jquery neither php so maybe Im missing something. Thank you for your help


title: bulk deleting empty items in the media library

text: I wrote a function, which should rename my attachments, based on the post title. Unfortunately this function created over 10.000 empty instances in my media-library, before I was able to stop it. The instances are all attached to a single post, which I could delete if it's necessary. I'm really sorry to bother you with the ask for help, but I'm a bit scared to screw things up again.


title: Moved Wordpress site to new server, directory permissions not working correctly

text: I built a Wordpress on my hosting space and then transferred it my clients server - followed all the instructions and pretty much everything works fine. The ONLY problem I have is that the directory permissions aren't working correctly, they're all set correctly (generally 755) - but I cannot update/install plugins and cannot upload media. Any ideas? Thank you


title: Installed domain-based Multisite but can't access wp-admin (redirect loop)

text: I've installed a domain-based Multisite on my server, and everything works including each of the subdomains. Here I should explain that I imported a Database that was on my Local Mac, and then changed the details in the database for each site. However, I now can't access wp-admin for the main domain or any of the subdomains, Chrome just tells me there is a Redirect Loop (http://cl.ly/Qg7K). Let me just clarify that I can't access wp-admin at all, i.e not even the login page. I'm reasonably confident with Wordpress, Databases and servers, so I can most likely get any data back for you and carry things out to test, try to fix etc. Thanks for any help! **EDIT** : People asked for my .htaccess code. It was copied from my localhost installation but I was using a Virtual Host so there were no paths involved. I'm no expert with .htaccess though so something could be wrong.               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]          # add a trailing slash to /wp-admin     RewriteRule ^wp-admin$ wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^(wp-(content|admin|includes).*) $1 [L]     RewriteRule ^(.*\.php)$ $1 [L]     RewriteRule . index.php [L]


title: Adding a custom admin page

text: I want to add a page of content (a readme file) in the WordPress admin, I can't seem to find how to do this in the codex - can anyone point me in the right direction? It will literally just be a simple page with a few paragraphs of content.


title: Asian language multisite IDN subdomain

text: Using an IDN internationalized domain name in Thai appears to work fine. However when using WP Multisite Subdomain network and trying to ADD SITE as a SUBDOMAIN - it is not accepting the Thai characters and generates error "Missing or invalid site address." I tried changing some setting in phpMyAdmin collation and wp-config.php but didn't really know what to do with that, and plugin intlWP which looked like it would do it, has not fixed the problem of using Thai as the subdomain site address. this isn't a translation issue, it's a URL and WP Admin interface issue I think. there has to be a way to have a WP multisite using Thai language subdomains... any suggestions welcome. thanks


title: Custom Post Type Definition should not be in the theme - how?

text: Is there a way to define a custom post type independent from a theme? All sources I found in the web do that in the theme, fuctions.php or via including other theme-specific php-files. But in my eyes this makes no sense. Where is the separation between content (custom post type) and layout (theme)? An other problem I see is changing the theme. Data is still in database, I know, but no way to edit or add new items.


title: Possible to enqueue scripts and CSS to Multisite Network dashboard?

text: Is it possible to enqueue scripts and css **only** to the Network Admin Dashboard? To edit the network admin menu, you have this hook: `network_admin_menu`, so I also tried `network_admin_enqueue_scripts`, but this didn't work. Thanks! Roc.


title: Search results highlight breaks my read more link

text:
I am attempting to add highlighting to my search results in the theme that I am coding. I found the way to do it on this thread: How to highlight search terms without plugin and it worked wonderfully. However, it is conflicting with my read more link whenever a permalink contains the search term by trying to do the replacement in the read more link causing the link to break oddly. Does anyone have a suggestion or fix for it? The following codes I use are as follows:               function search_excerpt_highlight() {         $excerpt = get_the_excerpt();         $keys = implode('|', explode(' ', get_search_query()));         $excerpt = preg_replace('/(' . $keys .')/iu', '\0', $excerpt);         echo '
' . $excerpt . '
';     }          function supralegal_auto_excerpt_more( $more ) {         return '…' . supralegal_read_more_link();     }     add_filter( 'excerpt_more', 'supralegal_auto_excerpt_more' );          function supralegal_read_more_link() {         return ' ' . __( 'Read more', 'supralegal' ) . '';     }


title: How to add categories to page editor?

text: I'm trying to add the categories selector to the "page" editor workspace. The code below does the trick, however, none of the values are saved with the page. Any help much appreciated!               add_action('admin_menu', 'my_post_categories_meta_box');     function my_post_categories_meta_box() {         add_meta_box('categorydiv', __('Categories'),              'post_categories_meta_box', 'page', 'side', 'core');     }


title: Run search query again without pagination gives no results?

text: ## Update: This question isn't really relevant anymore. I switched some code, so now the filtering works. Looks like the query wasn't working, because I triggered the `indexTaxonomyCounts` function from a template? But I now have another problem, but will write a different question for that. ## Original question: I want to filter my custom products by some taxonomy and meta filters. This works for regular queries, but not for my search results. At least, the filtering works, but getting the right counts somehow does not. What I do is the following:   * I hook in to the `pre_get_posts` hook and use the data from the $_GET to create taxonomy and meta queries.   * Then I store the query I just created (including the filtering), so on the result page I can calculate for each taxonomy/meta filter, how many results there totally are. But somehow when I run the stored search query again (but now with `posts_per_page=-1`) I get no results? No idea why. Does the search perform different queries then regular queries? Maybe it's more clear with some code snippets. The following function works, the search results are filtered and all:               add_action('pre_get_posts', array($this, 'pre_get_posts_hook'));          public function pre_get_posts_hook( $query_obj )     {         //check if this isn't the internal query, since that doesn't need filtering ^^         if( empty($query_obj->query_vars['internal-query']) || $query_obj->query_vars['internal-query'] != true ) {         $tax_query = array();         $meta_query = array();              if(isset($_GET['someMetaFilter']) {             foreach(explode(',', $_GET['someMetaFilter']) as $tax_value) {                 $meta_query[] = array(                     'key' => urldecode($tax_value),                     'value' => array(''),                     'compare' => 'NOT IN',                 );             }         }              if(isset($_GET['someTaxonomyFilter']) {              foreach(explode(',', $_GET['someTaxonomyFilter]) as $tax_id) {                 $ids[] = urldecode($tax_id);             }                  $tax_query[] = array(                 'taxonomy' => $type,                 'field' => 'term_id',                 'terms' => array_map('intval', $ids),                 'include_children' => false,                 'operator' => 'AND'             );         }              if(count($tax_query)) {             $tax_query['relation'] = 'AND';                  $query_obj->set('tax_query', $tax_query);         }              if(count($meta_query)) {             $meta_query['relation'] = 'AND';                  $query_obj->set('meta_query', $meta_query);         }              //only set it if we have set a specific filter set         if(count($tax_query) || count($meta_query)) {             self::$query_vars = $query_obj->query_vars;         }              return $query_obj;     }      This function is called from the result-page, to calculate all the counts for the taxonomies. But this just results in 0 results :S The only thing I do is getting the previously used query_vars and set the `post_per_page` to -1 (so I can get all the results, instead of only for this page)               public static function indexTaxonomyCounts()     {         if (isset(self::$query_vars)) {             $query_vars = self::$query_vars;             $query_vars['posts_per_page'] = -1;             $query_vars['internal-query'] = true; //to prevent the pre_get_posts_hook to adjust the query                  $wpQuery = new WP_Query($query_vars);                  //somehow in the regular query, this works. But when I do this in a search result page, the $wpQuery->have_posts() is empty! But the result page does have 30+ results or something :S                   // The Loop             if ( $wpQuery->have_posts() ) {                 while ( $wpQuery->have_posts() ) {                     ...                     do some calculations based on the taxonomy and such                     ...                 }             }                  /* Restore original Post Data */             wp_reset_query();         }     }      I tried so many things, I don't even know what anymore. I copied the query_vars, I copied the WpQuery. I tried to reconstruct the WpQuery by adding the `?s=$_GET['s']` or something. But to no result. So if anyone knows what's the cause of this, I would be so grateful! ## Additional information (1) Ok, I did some logging (using the `posts_request` filter and I have 2 dumps of data. It's way too big to dump it here. So I uploaded them to my Dropbox: This one works: https://www.dropbox.com/s/a07defqjx1d95j0/regular-page.php   And this one does not: https://www.dropbox.com/s/zboiw4fjqojotw7/search- page.php As you can see in the code snippets above, I just use the same query_vars. The two query_vars differ only slightly, but I'm not sure what's causing that. The `SELECT * FROM mug_posts WHERE 1=2` is weird, but the search does give back results - so I figured that search does some other query??? ## Additional information (2) Ok, it's getting even weirder. I simplified the logic, I stripped out the whole taxonomy filtering and such. In the `pre_get_posts` I store the query and on a page I call a function, which checks that stored query and runs that again. But I get no results back!               public function pre_get_posts_hook( $query_obj )     {         if( $query_obj->is_page() == false ) {             if( $query_obj->query_vars['post_type'] == 'products' ) {                     if ( ($query_obj->is_main_query() == false && $this->filterIsActive())                         || $query_obj->is_search()) {                         self::$query_vars = $query_obj->query_vars;                 }             }         }              return $query_obj;     }          public static function indexTaxonomyCounts()     {         if (isset(self::$query_vars)) {             $query_vars = self::$query_vars;                  $wpQuery = new WP_Query($query_vars);                  echo $wpQuery->have_posts(); // -> false                  /* Restore original Post Data */             wp_reset_query();         }     }      I printed the query_vars for a regular page and for the search page and they are almost identical: Query vars on a regular page: https:// www . dropbox.com /s/nxy75avclwtr5xt/results.php   Query vars on a search page: https:// www . dropbox.com /s/g72nhsfwej9q95c/no- result.php (sorry for the weird link, but I don't have enough reputation yet to post more links) You'd think since the query vars are (almost) identical, they'd give the same result. Nope :P


title: How to return number of found rows from SELECT query

text: I wrote a function which is supposed to return the number of rows found in a SELECT query but it always either seems to return 0 or an array. I have been messing around with this for about an hour now and I still can't figure it out! I'm sure I'm doing something stupidly wrong. The MySQL Table               +--------+-------------+---------------------+     | postid |     ip      |        time         |     +--------+-------------+---------------------+     |   1234 | 192.168.0.1 | 2014-01-29 14:27:02 |     |   5678 | 192.168.0.2 | 2014-01-29 14:27:02 |     +--------+-------------+---------------------+      PHP               ### Search for IP in database     function postviews_get_ip($id, $ip) {         global $post, $wpdb;              $wpdb->get_results("SELECT * FROM $wpdb->wp_postviews_ips WHERE postid = $id AND ip = $ip");              $rowcount = $wpdb->num_rows;              return $rowcount;     }          postviews_get_ip($id, $_SERVER['REMOTE_ADDR']);     //both $id and $_SERVER['REMOTE_ADDR']) return the values I'm searching for in the database


title: SQL query to update post_date (one post = one single date & time)

text: I have 120 posts of one category ready for my wordpress blog. For the moment, posts are drafts and I don't want to schedule them manually. I want to publish them like this:   * 4 articles each day from the 1st of August 2013   * 1 at 10am / 1 at 2pm / 1 at 5pm / 1 at 8:30pm What I need is the SQL query to:   * Update date_post for the 120 posts, based on the needs described above   * Change "draft" mode to "pending"   * The publication order is based on the creation date of the posts: the older will be the first published. I'm lost in the queries and loops. If someone could help, it would be very very appreciated. Thanks a lot, Chris


title: Dynamically Set Wordpress Post Title To The Category Name

text: I have a few custom post types set up. However, a couple of them have the title field removed from the edit screen because a title does not make sense in some aspects. However, I now find that all posts are being saved improperly with the text "Autosaved Post" or whatever. Is it possible to set the post title upon saving the post to be the assigned category name? The reason I want this is because I am building a record label website with the following custom post types:   * Artists   * Homepage Carousel   * Videos   * Tours The homepage carousel does not need a title and I would like it to perhaps be the following format: "Bandname Carousel" bandname being the category name of which would only be band names. Should I add the title field back in and use jQuery to perhaps set the title instead of writing a custom Wordpress plugin and set the field to read only so the user can't make changes to it? The reason I want to set the title is to stop the annoying "Autosaved Post" value being added to the title hence preventing the user from being able to sort through and differentiate between posts that have been added.


title: Custom Query num_rows returns wrong amount

text: So I have a custom query that fetches all posts in a given category. I am trying to get the number of rows returned but it is giving me the wrong number. Instead of 11, I am getting 14. Does anyone know why?               <?php     $pageposts = $wpdb->get_results($wpdb->prepare("         SELECT * FROM $wpdb->posts         LEFT JOIN userContests ON ($wpdb->posts.ID = userContests.contestID)         LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)         LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)         WHERE $wpdb->posts.post_status = 'publish'          AND $wpdb->posts.post_type = 'post'          AND $wpdb->posts.post_date < NOW()          AND $wpdb->term_taxonomy.taxonomy = 'category'         AND $wpdb->term_taxonomy.term_id IN(3)         ORDER BY $wpdb->posts.post_date DESC         "), OBJECT);          /*   $rows = $wpdb->num_rows;  <------ Wrongly returns 14 */          /*   $rows = $wpdb->get_var($wpdb->prepare("      <--------- Correctly returns 11             SELECT COUNT(*) FROM $wpdb->posts             LEFT JOIN userContests ON ($wpdb->posts.ID = userContests.contestID)             LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)             LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)             WHERE $wpdb->posts.post_status = 'publish'              AND $wpdb->posts.post_type = 'post'              AND $wpdb->posts.post_date < NOW()              AND $wpdb->term_taxonomy.taxonomy = 'category'             AND $wpdb->term_taxonomy.term_id IN(3)             ORDER BY $wpdb->posts.post_date DESC")); */     echo "Number of rows = " .$rows;     ?>      My work around seems like a waste of resources. Is there something more efficient?


title: Settings api sanatize callback not being triggered

text:
I'm creating a custom settings page for a custom theme however the callbacks for sanatizing the data in the fields are not being called (I put in xdebug breakpoints in them to check).               /**     *------------------------- Admin Page Titles -------------------------     */          function header_options_text() {         echo '
These options affect the Header content.
';     }          /**     *------------------------- Header Options -------------------------     */          function phone_number_input() {         $option = get_option('header_phone');         echo '<input id="header_phone" name="header_phone" size="40" type="text" value="'.$option.'"> </input>';     }     function header_logo_input() {         $option = get_option('header_logo');         echo '<input id="header_logo" name="header_logo" size="40" type="text" value="'.$option.'"> </input>';     }          /**     *------------------------- Header Validation Options -------------------------     */          function header_phone_validate($input) {         $new_input=trim($input);         if(get_option( 'header_phone' ) === $new_input || !preg_match('/^[\+\d\(\)\- ]*$/', $new_input))             $new_input=get_option( 'header_phone' );         return $new_input;     }     function header_logo_validate($input) {         $new_input=esc_url_raw(trim($input));         if(get_option( 'header_logo' ) === $new_input && !filter_var($new_input, FILTER_VALIDATE_URL))             $new_input=get_option( 'header_logo' );         return $input;     }          /**      *------------------------- Actually create the pages and add to menu -------------------------      */          add_action( 'admin_menu', 'ec1_admin', 10, 0 );     function ec1_admin() {         add_menu_page( 'EC1 Theme Options', 'EC1 Theme Options', 'manage_options', 'ec1-theme-options', 'ec1_theme_options_page' );     }          function ec1_theme_options_page() {         ?>

EC1 Theme Options
             <form action="options.php" method="post">                 <?php settings_fields('header-options'); ?>                 <?php settings_fields('header-logo-options'); ?>                 <?php do_settings_sections( 'ec1-theme-options' ); ?>                 <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />             </form>
         <?php     }               add_action('admin_init', 'plugin_admin_init');     function plugin_admin_init(){         register_setting( 'header-options', 'header_phone', 'header_phone_validate' );         register_setting( 'header-logo-options', 'header_logo', 'header_logo_validate' );         add_settings_section('header-options-pane', 'Header Options', 'header_options_text', 'ec1-theme-options');         add_settings_field('header_phone', 'Phone Number', 'phone_number_input', 'ec1-theme-options', 'header-options-pane');         add_settings_field('header_logo', 'Header Logo', 'header_logo_input', 'ec1-theme-options', 'header-options-pane');     }     ?>


title: Do I have anything to worry about when switching to a default theme to test for plugin conflictions?

text: WordPress noob here. I want to test a site I'm working on for plugin conflicts. I've heard that switching to a default theme and testing the plugins will do this. My question is, is this going to mess my theme up when I reactivate it? Is it going to be as simple as hitting 'reactivate'?


title: Is there a way to localize role labels?

text: I'm using Justin Tadlock's Members plugin to create new roles and WP Role on Registration to display them on the registration form. I've got a multilang site (English and Spanish) and I've localized my custom taxonomies using qTranslate. I can't use qTranslate's quicktags in the Role Label field on the Member's plugin because it doesn't save it properly (even with `$new_role_label = strip_tags( $_POST['role-label'] );` commented out on role-new.php) and I can't go into the database to make the changes there because then it breaks. I've seen very scarce info about the WP function translate_user_role but I'm not sure it. There's not much else to go on.


title: How do I modify this wpdb query to include posts that have a post_status of publish and draft?

text: I'm using the following function to count the number of posts an author has made from a custom post type.               <?php     function count_user_posts_by_type($userid, $post_type) {         global $wpdb;         $where = get_posts_by_author_sql($post_type, TRUE, $userid);         $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );         return apply_filters('get_usernumposts', $count, $userid);     }     ?>        To echo out the count I use               <?php echo count_user_posts_by_type(wp_get_current_user()->ID, 'custom_post_type_name'); ?>      From my testing it seems to count just the posts that have a `post_status` of `publish`. How can I modify the function so it also counts posts that are `draft` ? I've tried to modify the query as follows but it seems to have no effect whatsoever:               $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where AND post_status IN ('publish','draft')" );


title: How to best include widget area just on homepage?

text:
I have a front-page.php defining the homepage of my theme (a Genesis child theme). In it, I have some custom widget areas, like so:               genesis_register_sidebar( array(         'id'    => 'cta',         'name'    => __( 'How do I Connect?', 'site' ),         'description'    => __( 'This is the cta widget for the home page.', 'site' ),     ) );          add_action( 'genesis_after_header', 'cta_widget' );          function cta_widget() {        genesis_widget_area( 'cta', array(            'before' => '

How do I Connect?
',            'after' => '

'        ) );     }      I originally had it in the functions.php and it worked fine.. I added some widgets to it, etc with no problems. But now I moved it to front-page.php as I saw mentioned as a way to restrict it to the home page, and now it is listed under inactive widgets, although I can still edit them it is confusing for the user, plus I cannot add any more in this way. Is this expected behaviour?


title: How can I let users access a specific attachment?

text: I'm trying to add a XML file to my site that users can access when I give them the url. www.domain.com/blank01/blank02/file.xml As of right now, blank01 and blank02 don't exist as pages. Down the road they will have content and links that eventually take you to "file.xml" and others. But for right now I just want to put this file on my WP and make it accessible to my users when they go to this specifically designated url, but I can't figure out how to. I tried to upload it to the library, but the file type wasn't accepted, but I fixed that. Once I did get it uploaded to the library, I couldn't change the link. Also, what do I need to do to make blank01 and blank02 exist without being pages, just categories for now? Or do they have to be pages?


title: Wordpress pagination on custom script

text:
I am using WP for my RealEstate project where all properties are pulled from a custom table (wp_listing) and displayed in a custom page template (page- realestate.php). I know WordPress has built-in pagination methods to deal with paged content (pages, posts lists). I want to use that same pagination methods for the list of properties I am fetching from my custom DB table. Is this possible? How? [EDIT] Code is something like:               echo '
';     $properties = $listing->getProperties();     for($i = 0; $i < count($properties) ; $i++) {         echo '
' . $properties[$i]['address'] . '
';     }     echo '
';


title: How to allow wordpress to create username with symbols like +

text: I want to allow users to create username with **+** symbol. but wordpess removing the symbol by the register validation process. If I gave username as **abcd+123** , the user registered with username as **abcd123**. I need the username registered as it is with **+** symbol. Answers are greatly appreciated.


title: How to change the output of gallery shortcode

text: I would like to **add the media description as a data-attribute** to each image of the gallery. All the other answers favour the solution to copy the whole code from media.php to functions.php and change it there. But isn't there a more intelligent way? It's way to much **code duplication** in order to change one single line of code!


title: Previous/Next Link by Meta Value in CPT

text: I'm using the following code to paginate between custom post types and it doesn't seem to be using the meta_key or meta_value_num and I can't figure out why. The CPT is set-up to have hierarchal => true and the Capability type is a page. This is the code I'm using for paging (which doesn't seem to make a difference --I tried using orderby=menu_order and that didn't work either).               <?php if     (get_adjacent_post(false, '', true))     {  echo previous_post_link('%link' , '');  }     else     { echo previous_post_link('%link' , '');     $newest_post = get_posts('post_type=employee-bios&posts_per_page=1&order=DESC&meta_key=display-order&orderby=meta_value_num');  $newest_post_id = $newest_post[0]->ID;     echo '     '; }      ?>          <?php if     (get_adjacent_post(false, '', false))         {  echo next_post_link('%link' , ''); }     else         { echo ''; $eldest_post = get_posts('post_type=employee-bios&posts_per_page=1&order=ASC&meta_key=display-order&orderby=meta_value_num');  $eldest_post_id = $eldest_post[0]->ID;     echo ''; } ;      ?>      And this is my WP_Query (which doesn't seem to matter in the scheme of things either--I'd started off just using while have posts and when that didn't work, I tried the WP_Query)               <?php     $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;     $args = array(         'post_type' => 'employee-bios',         'posts_per_page' => 1,         'orderby' => meta_value_num,         'meta_key' => 'display-order',         'order' => 'ASC',         'paged' => $paged     );     $my_query = new WP_Query( $args );     ?>      My client wants to be able to select the order of the employee bios on a landing page and they should paginate in the order they've been placed on the landing page (which is why I tried using both menu_order and a custom field meta value for sorting). I've also tried changing the Capability type from page to post and that doesn't seem to make a difference either. Any help would be much appreciated. Thanks!


title: Show featured image in sidebar

text:
I'm adding a widget on my sidebar but the Featured Image isn't shown. this is the code of my side bar:               <?php     /**      * The Sidebar containing the main widget areas.      *      * @package PowerMag      * @since PowerMag 1.0      */     ?>         <div id="sidebar" <?php if ( of_get_option('pm_sidebar_position') == 'sidebar-content' ) { echo 'class="span4"'; } ?> >
                  <?php do_action( 'before_sidebar' ); ?>                           <?php                           //Select wich sidebar will be display                     $selected_sidebar_replacement = 'sidebar-1'; //Default Sidebar                          //If is page or single.                     if(is_singular()){                              global $wp_query;                         $post = $wp_query->get_queried_object();                         $selected_sidebar_replacement = get_post_meta($post->ID, 'sbg_selected_sidebar_replacement', true);                              //If default selected                         if($selected_sidebar_replacement == '0' || $selected_sidebar_replacement == ''){                             $selected_sidebar_replacement = 'sidebar-1';                         }                              // Reset the global $the_post as this query will have stomped on it                         wp_reset_query();                          }                                 if (function_exists('dynamic_sidebar') && dynamic_sidebar($selected_sidebar_replacement)) : else : ?>
You selected an empty sidebar, try populating it with some awesome widgets!
                      <?php endif; // end sidebar widget area ?>


title: Wordpress updater conflict

text: I have created a theme named "landscape" and it's still on version 1.0 but I am getting notified in wordpress updates dashboad that there is a new version 1.0.3 If I click on update the free theme on wordpress theme directory overwrite my own theme. I don't understand this conflict .. I renamed the theme in style.css but I am still encountering the same issue. Please help.I don't want to rename the folder name of the theme. is there a way to prevent the updates from wordpress.org api? Thank You


title: Remove duplicate attachments

text: Here is the situation: I have an automated script that upload attachments and link each attachment to a specific post. By mistake, the script run multiple times and I have the following   1. More than one attachment post in the Media library for a single file (the different attachment posts have the same File URL).   2. One of these attachment is actually attached to the post. What I want to do is obviously is clean up the media library. I need to remove the attachment post without removing the file, and also make sure that I don't remove the ones that are actually attached to their posts. Any ideas?


title: 3.9 Galleries & Thumbnails

text: I'm using WP 3.9.1 and have added a gallery (Add Media ->Create Gallery -> pick images -> Gallery Settings: Link to Media File.) That works, almost. The problem is that I need the gallery to use the custom size thumbnails I specified in my functions file. So I go into the text editor and change the gallery shortcode from               [gallery link="file" ids="672,540,537,556,557,541,558,535,555"]      to               [gallery size="thumbnail" link="file" ids="672,540,537,556,557,541,558,535,555"]      Adding the "size=thumbnail" works. However, it is not easy to do from the Media Manager / Gallery Editor. Am I missing something? I can't ask a client to remember to add this everytime. And what's worse is that any time you ADD photos (or otherwise edit the gallery), you have to switch to the Visual editor to make changes and when you click Update Gallery, it overwrites the "size=thumbnail" that was added. Is there a snippet of code I can add to my functions file to force the size?


title: Per theme plugins?

text: I'm building a plugin that heavily modifies the commenting section of a blog page. It think that I cannot do this in a way that works with all themes — some CSS has to be tweaked, depending on the particular theme in use. I'd guess that in the future, the plugin will also store some data in the database. So I suppose it should be a plugin, not a theme. (?) Hence these questions:   1. Is it possible to in some way indicate that a plugin works with only this and that theme?   2. And then release some fairly simlar versions of the plugin, each version tweaked for a specific group of themes?   3. Or are plugins supposed to work well with... all themes in existance?   4. Can you think of some solution other than per-theme-plugins and/or forking-and-modifing-existing-themes? Perhaps child themes? But, no, then it would not be possible for users-of-my-child-theme to create their own child themes?


title: wordpress permalinks tweeks

text: I am getting following permalink structure after creating any post... http://domain.com/wp/postname As per Permalink Settings.... Post name: http://domain.com/wp/sample-post/ This permalink is fine for pages, but how can i add blog as prefix like following.... http://domain.com/wp/ **blog** /postname http://domain.com/wp/ **blog** /category/postname Let me know if you need more information Please help, thanks.


title: Get current logged in user under 3.1, re: remove "Howdy"

text: I use this in functions.php to change "howdy" to "Logged in as...." But now under 3.1 I get "Logged in as Your Profile" rather than "Logged in as `<current user>`" What needs to be changed so that "user" below (commented below as `//get current user?)` returns the current user in 3.1?               if (is_admin()) {         add_action('init', 'better_howdy_h');         add_action('admin_footer', 'better_howdy_f');              function better_howdy_h() {             wp_enqueue_script('jquery');         }              function better_howdy_f() {     ?>     <script type="text/javascript">     /* <![CDATA[ */         var user = jQuery('#user_info p a:first').text();         var howdy = jQuery('#user_info p')             .html()             .replace(/<.+>/ig,'')             .replace(/\ \|\n/ig,'');         jQuery('#user_info p')             .html(                 jQuery('#user_info p')                     .html()                     .replace(user,'My Profile')             .replace(howdy,'Logged in as ' + user + ' | ') //get current user?                     .replace('!',' |')                     .replace('| |','|')             );     /* ]]> */     </script>     <?php          }      }


title: register_sidebar ignores 'id' and 'class'

text:
I am using the following to register a widget area:               if ( function_exists('register_sidebar') )         register_sidebar( array(         'name' => __( 'Footer Widgets', 'hex'),         'id' => 'footer-widgets',         'class' => 'footer-widgets',         'description' => __( 'Widgets will appear in the blog, between the end of content and footer', 'hex' ),         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
'     ) );      And both `id` and `class` are ignored, what I get is only the widgets themselves - the top element in the widget area is the `<li>` I know I can simply wrap it in the `index.php`, where the widgets show, with a div, but isn't this suppose to do it?


title: Which files can be replaced in a child theme?

text: I have a website which is using a child theme of Twenty Twelve.   As part of the design process, I had to edit `/twentytwelve/css/ie.css`. Is it possible to save this file in my child theme, and keep twentytwelve's version as it was by default? This would ensure if Twenty Twelve is ever updated, I won't lose the changes I made to `/twentytwelve/css/ie.css`.


title: I'm having several WP issues, especially with missing images

text: My site is at http://www.aviewtoathrill.net. I have deactivated all of my plugins in the hopes of getting my images to show up on the site. Since it is a travel site, images are crucial. I think the problem began when I installed w3 total cache because the site was very slow. That plugin caused me to have lots of problems with redirection. I installed disable canonical url plugin which helped temporarily until the whole site crashed. I uninstalled both of those plugins. Also, I switched hosts from fatcow to stablehost, so I'm not sure if that may have affected things. Additionally, I upgraded my wordpress from 2.9 to 3.1. Secondly, I realize with all of my images, I need external storage. I have started an amazon s3 and cloudfront account. However, I can't figure out how to transfer the files/folders. Please feel free to ask for clarification. I'm sure it sounds like I'm rambling, I just want to find someone who can fix my problem completely for once and for all. Oh, I just reinstalled my broken links plugin and it says that 534 image links are broken....just thought that I would add that. Thank you! Renee


title: wp_list_categories link to first post of category instead of calling taxonomy template

text: I'm using wp_list_categories to give me a list of links to categories (no surprise there) Is it possible to get Wordpress to link to the first post of a given category instead of calling the taxonomy template which displays links to all posts in that category?


title: Recommend plugins for member's only e-commerce website

text: I welcome recommendation from the gurus for my ecommerce website - I want to make a ecommerce website and I want it to be for members only. I want to restrict members from visiting the dashboard. I want guest-visitors to land on a login page , and once they login to my website they would be able to provide billing address, contact information, they would be able to shop, track orders status. Can anyone suggest me what plugins and theme (free and premium both) would be best for my website ? I would sell T-shirts and Canvas shoes . The extra (must) features I want for my ecommerce website:   1. members only website (only login page visible to non-logged in visitors)   2. members will have a profile page where they can update the billing and shipping information, which will be used in future for all shopping transactions they make, with a confirmation during finalising the order.   3. HTML Email and Newsletters P.S. - I have tested eshop (Wordpress Plugin). I liked it. But the only two problems with this plguin is that   1. the orders can only be tracked from the dashboard, and I have asked the developer about the code to make order tracking system a frontend page, but the developer said thats not possible.   2. No members profile page to update and save billing and shipping address (Shoppers have to fill in the personal infomations every time they order something which is annoying). Isn't there any solution at all?


title: a featured content slider like this

text: I have seen one of the best featured content slider here: http://www.elegantthemes.com/preview/Polished/ Can you recommend me a plugin to replicate it in my own wp theme? Thanks!


title: Where is the submitted $_POST array stored after an option page submission?

text: What happens, when I click `Save Changes` on a option page, which was created by `add_menu_page()`? Where is the submitted data stored _before_ the database transmission? A `print_r($_REQUEST)` returns only the two `$_GET` parameters `page` and `settings-updated`. I've checked the manual for `add_settings_field` and there is only the following hint: > ... the saving will be done behind the scenes. ## Background I'd like to optimize my process of creating a plugin settings page. I've already jumped on the WP Settings API with `add_settings_section` and `add_settings_field` long time ago, but it feels a bit uncomfortable to create a new callback function every time. So instead of creating the specific field/section code inside a callback, I'd like to create the complete settings page with `Zend_View`. All input fields would be created with `Zend_Form` and also attached to the view. In the end, the callback of `add_menu_page()` will return the rendered View-Object instead of the normal HTML output. The HTML is stored inside a View-Template, located in `views/pages/admin/` (e.g. `default.phtml`). The basic principle is already working I'm very happy with the result. Due to the use of `Zend_View`, I've to do the saving on my own. But WordPress seems to delete the submitted $_POST array. If I debug the output after a successfull form submission, only the two `$_GET` params above are set. I've also attached the output of the function `settings_fields()` to the view, which generates the required hidden fields (`option_page`, `action`, `_wp_nonce`). Any ideas?


title: Page permalink rewrite

text: I added the following code which allows categories on my 'Page' post type.               add_action('init', 'edit_page_type');     function edit_page_type()      {         register_taxonomy_for_object_type('category', 'page');     }      Now i realize the permalinks dont exactly match... How can i rewrite the page permalinks to act like the post permalinks? (which include the category before the page title)


title: How to set up multiple taxonomies for groups of posts

text: I have a site that has several types of posts, with categories for each: a News section (categories: Local, International, Breaking), a Video section (categories: Music, Kids, Holidays), and a Photo section (categories: Wedding, Portrait, Landscape). Unfortunately out-of-the-box, Wordpress is set up for a group of posts. But I need a way to present the various sections/categories in the admin (and set up in my code) in a simple clear way. I think I should set up custom post types for each of the main types of posts (News, Video, Photo) and then custom taxonomies assigned to each of those... is that right? Just want to find the most flexible, correct way to accomplish what I'm trying to do. The user should always be able to edit the categories for each type of post, and ideally I'd like the flexibility for the user to add new types of posts if possible. Thank you.


title: Link name in comments to Author page? Comment Author Meta in Comments?

text: I wasn't exactly sure how to word the question, so I'm sure that's why I cannot find what I need when searching Google either. I want to link all commenter names to their author.php page if they have `edit_posts` capability (Authors, Editors and Admins), otherwise link to the website they have listed in their profile. I am not experienced with using `comment_author`. Thanks.


title: Query a custom taxonomy for certain posts

text:
I am trying to show some posts on a template based on their custom taxonomy. Here is my template code:               <?php $field = get_field('newsletter_date'); ?>                     <?php                      $args = array (                     'orderby'                => 'rand',                     'taxonomy' => 'newsdates',                     'field' => 'id',                     'terms' => "$field",                     'post_type' => 'post',                     );                          $queryarticles = new WP_Query( $args ); ?>                          <?php while ($queryarticles -> have_posts()) : $queryarticles -> the_post(); ?>
<a href="<?php the_permalink() ?>" class="nound"><?php the_title(); ?>
                                                   <?php the_content(); ?>                                               <?php endwhile;?>                     <?php wp_reset_postdata(); ?>      and here is what is in my function.php:               // Register Custom Taxonomy     function newsdates_taxonomy()  {              $labels = array(             'name'                       => _x( 'Newsletter Dates', 'Taxonomy General Name', 'text_domain' ),             'singular_name'              => _x( 'Newsletter Date', 'Taxonomy Singular Name', 'text_domain' ),             'menu_name'                  => __( 'Newsletter Date', 'text_domain' ),             'all_items'                  => __( 'All Newsletter Dates', 'text_domain' ),             'parent_item'                => __( 'Parent Date', 'text_domain' ),             'parent_item_colon'          => __( 'Parent Date:', 'text_domain' ),             'new_item_name'              => __( 'New Date', 'text_domain' ),             'add_new_item'               => __( 'Add Newsletter Date', 'text_domain' ),             'edit_item'                  => __( 'Edit Date', 'text_domain' ),             'update_item'                => __( 'Update Date', 'text_domain' ),             'separate_items_with_commas' => __( 'Separate dates with commas', 'text_domain' ),             'search_items'               => __( 'Search dates', 'text_domain' ),             'add_or_remove_items'        => __( 'Add or remove dates', 'text_domain' ),             'choose_from_most_used'      => __( 'Choose from the most used dates', 'text_domain' ),         );         $args = array(             'labels'                     => $labels,             'hierarchical'               => false,             'public'                     => true,             'show_ui'                    => true,             'show_admin_column'          => true,             'show_in_nav_menus'          => true,             'show_tagcloud'              => true,         );         register_taxonomy( 'newsdates', 'post', $args );          }          // Hook into the 'init' action     add_action( 'init', 'newsdates_taxonomy', 0 );          }


title: add_actions called from functions.php not returning good values

text: I am trying to add some security/acccess prevention to my site via the functions.php. However whenever I try to add through functions.php (instead of as a plugin, which I've done in the past) it fails (always returns false). For example:               add_action("parse_query", checkaccess());  // in functions.php      and               function checkaccess() {         $allowAccess = false;              if(is_admin()||is_front_page()||is_home()||current_user_can('administrator'))             $allowAccess=true;              if($allowAccess)             echo 'whatup'; //do something here          }      even if i try something basic - eg `global $wp_query; var_dump($wp_query);` I can't get the query var, its all NULL. Any advice? Is there some kind of walled sandbox the fuctions.php file operates from that it can't get any of these?


title: Custom post rewrite rule not working

text: I'm adding a custom post type like so (names have been altered to protect the innocent):               add_action('init', 'my_post_types');     function my_post_types() {            register_post_type('publication',         array(           'labels' => array(...),           'rewrite' => array(             'slug' => 'publications/%year%',             'with_front' => true             ),           'public' => true,           'menu_position' => 21,           'supports' => array('title', 'editor', 'author', 'excerpts', 'revisions', 'thumbnail'),           'show_ui' => true,         ));     }      I would expect with these settings that the URL of a given publication would be:               /publications/2012/name-of-publication      However, the URLs produced by `get_permalink()` are coming out as:               /publication/name-of-publication      The desired URL pattern is recognised by WordPress, but simply redirects to the lower URL. This URL does display the desired page. I've tried the commonly suggested solutions:   * Making sure that `register_post_type` is called on the `init` action, so it isn't created too late.   * Flushing the rewrite rules by visiting the Permalinks settings page. I also tried doing this on every page using `$wp_rewrite->flush_rules()`, but that would be pointlessly expensive in reality.   * Changing the value of `with_front` has no effect. I wouldn't expect it to since the site is at `/`, not in a subfolder.   * Taking out the `%year%` part of the slug has no effect either, so it isn't causing the rewrite rules to fail.   * I don't have the Redirection plugin installed. It's a known troublemaker with URLs. If necessary, I can intercept WordPress' routing and force it to deliver the right page, and use filters to return the right URL from `get_permalink`, but that seems like the wrong solution. Setting the rewrite rules when I register the post type is the right solution. Is there something I'm doing wrong?


title: Using Multiple Queries of "home_url" vs. Calling a Variable Multiple Times

text:
## Question Since I am using multiple instances of `home_url()` in one page template, I was curious if the following method would speed up my page load time. My method is to store the output of `home_url()` within a variable and then call that variable each time, rather than using `home_url()` each time. ## Motivation The reason I thought echoing a variable would be speed up the page load time, is because (if my understanding is correct) echoing a variable wouldn't require querying the database, each time I called that variable. ## Method A

<a href="<?php echo home_url(); ?>/category/blue">Blue Items

<a href="<?php echo home_url(); ?>/category/green">Green Items

<a href="<?php echo home_url(); ?>/category/red">Red Items

<a href="<?php echo home_url(); ?>/category/orange">Orange Items

<a href="<?php echo home_url(); ?>/category/purple">Purple Items

<a href="<?php echo home_url(); ?>/category/gray">Gray Items

      ## Method B               <?php $my_home_url = home_url(); ?>

<a href="<?php echo $my_home_url; ?>/category/blue">Blue Items

<a href="<?php echo $my_home_url; ?>/category/green">Green Items

<a href="<?php echo $my_home_url; ?>/category/red">Red Items

<a href="<?php echo $my_home_url; ?>/category/orange">Orange Items

<a href="<?php echo $my_home_url; ?>/category/purple">Purple Items

<a href="<?php echo $my_home_url; ?>/category/gray">Gray Items


title: Adding class to next/prev image link in attachment.php

text: Is it possible to add a class or ID to next/prev image links in `attachment.php`? I tried like this but it didn't work:               <?php next_image_link( false, 'Next', array('class' => 'next')); ?>


title: Most efficient way to search for values from CPT in Post content

text: I have a Glossary CPT. Title, editor, slug and featured image. I would like to add a filter to Post content (and content of my other CPT "species") which looks through all of the content in each post and replaces any words found in the Glossary with a link to the glossary entry. For example... _Glossary entry_ : test _Post content_ : `<p>This is a test post to explain what I mean.</p>` _Outcome after filter_ : `<p>This is a <a href="/glossary/t/test/">test</a> post to explain what I mean.</p>`. There may be up to 2000 glossary entries at any given time however, so I'm worried about efficiency. * * * **EDIT: THIS CODE NEEDS SOME REWORKING!** I've started to use code as suggested by Matthew Boynes. I have adapted it somewhat, as I was receiving an error with my `$wordlist` variable. More information on said error is available here.               function add_glossary_links($content) {         global $wpdb, $wordlist;         if ( !$wordlist && !$wordlist = get_option('wordlist') ) {             mysql_query('SET SESSION group_concat_max_len = 100000');             $wordlist = $wpdb->get_var('SELECT GROUP_CONCAT(DISTINCT post_title SEPARATOR "|") AS list FROM '.$wpdb->posts.' WHERE post_status="publish" AND post_type="glossary" AND post_parent>0');             add_option('wordlist', $wordlist);         }              $wordlist = str_replace(array(" ", "'", ".", "/"), array("\s", "\'", "\.", "\/"), $wordlist);              $content = preg_replace_callback(             '/\b('.$wordlist.')\b/i',             create_function(                 '$matches',                 'return "" . $matches[0] . "";'             ),             $content         );              return preg_replace('/(<[^<]+)(.*?)<\/a>/si','$1$2', $content);     }          add_filter( 'the_content', 'add_glossary_links' );      The function above works, to an extent. I now have two issues:   1. The function is linking _everything_ : `[caption id="attachment_542" align="alignleft" width="125" caption="Amazonas Magazine - now in English!"]<a href="http://www.seriouslyfish.com/dev/wp-content/uploads/2011/12/Amazonas-English-1.jpg"><img class="size-thumbnail wp-image-542" title="Amazonas English" src="http://www.seriouslyfish.com/dev/wp-content/uploads/2011/12/Amazonas-English-1-288x381.jpg" alt="Amazonas English" width="125" height="165" /></a>[/caption] <p>Edited by Hans-Georg Evers, the magazine ‘Amazonas’ has been widely-regarded as among the finest regular publications in the hobby since its launch in 2005, an impressive achievment considering it’s only been published in German to date. The long-awaited English version is just about to launch, and we think a subscription should be top of any serious fishkeeper’s Xmas list…</p> <p>The magazine is published in a bi-monthly basis and the English version launches with the January/February 2012 issue with distributors already organised in the United States, Canada, the United Kingdom, South Africa, Australia, and New Zealand. There are also mobile apps availablen which allow digital subscribers to read on portable devices.</p> <p>It’s fair to say that there currently exists no better publication for dedicated hobbyists with each issue featuring cutting-edge articles on fishes, invertebrates, aquatic plants, field trips to tropical destinations plus the latest in husbandry and breeding breakthroughs by expert aquarists, all accompanied by excellent photography throughout.</p> <p>U.S. residents can subscribe to the printed edition for just $29 USD per year, which also includes a free digital subscription, with the same offer available to Canadian readers for $41 USD or overseas subscribers for $49 USD. Please see the <a href="http://www.amazonasmagazine.com/">Amazonas website</a> for further information and a sample digital issue!</p> <p>Alternatively, subscribe directly to the print version <a href="https://www.amazonascustomerservice.com/subscribe/index2.php">here</a> or digital version <a href="https://www.amazonascustomerservice.com/subscribe/digital.php">here</a>.</p>`   2. This may be a pushing my luck, but would it be possible to make this code case-sensitive, i.e. content only matches wordlist if case is the same, unless it's the first word of a sentence? Thanks in advance,


title: Post_count only shows the number of results per page

text: I have a wp_query `$wp_query = new WP_Query($args);` but for some reason the `$wp_query->post_count` only shows the amount of posts on each page. So if I set `'showposts' => '10'` and 12 results are found, page one will say '10 results found' and page 2 shows '2 results found'. Why is this? I can't figure it out.               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(       'post_type' => 'post',        'showposts' => '10',       'paged' => $paged     );     $wp_query = new WP_Query($args);     echo "Search found ".$wp_query->post_count."results";     if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();     // the loop


title: How Can I Access a PHP Variable in Another PHP Function

text:
I'd like to use the $atts variable from the lax_google_map_maker() function in lax_google_map_init(). How do I access it? I tried to 'globalize' it, but for some reason it didn't work.               function lax_google_map_init() {         wp_enqueue_script('google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false');         wp_enqueue_script('lax_google_map_script', plugins_url('js/lax_google_map_script.js', __FILE__), array('google-maps','jquery'));              $params = array (            'latitude'=>  '39.01',            'longitude'=> '-76.02'             );              wp_localize_script('lax_google_map_script', 'lax_map_params', $params);      }          add_action('init', 'lax_google_map_init');               function lax_google_map_maker($atts,$content=null) {               $atts = shortcode_atts( array(             'latitude'=>'38.9205',                    'longitude'=>'-77.04505920410156'),             $atts);              $output .= '

';              return $output;     }                add_shortcode('lax-google-map', 'lax_google_map_maker');      * * * My goal is to set the $params variable using the shortcode's $atts. As I understand it, I have to keep the $params variable in the same function as the wp_enqueue_script line and the wp_localize_script line. Otherwise, I would break it out into a new function and pass in the $atts as a parameter. If there were a way to pass in $atts to function lax_google_map_init, I would be golden. I've tried everything that I can think of. Looking forward to hearing your good ideas.


title: Shortcode for tables which can include comma and linebreaks

text: Is it possible to make a shortcode for table which can include commas and linebreaks for its content? I've been trying to output something like this with shortcode: ![enter image description here](http://i.stack.imgur.com/ue4N1.png) But it seems difficult. I tried Google and found **this** and **there**, but what given there don't seem to allow commas within the content (as it is separated by comma) and can't seem to have linebreaks. Is this actually possible? Or is there any viable alternatives to achieve this? **I'm avoiding using plugin, only tried to mingle around with functions.php**. Thanks a lot for the help. :)


title: call user func array error after moved the site to new server

text: my wordpress site moved to a new server with cpanel. now after logged into wp- admin an error is showing.               call_user_func_array() expects parameter 1 to be a valid callback, function 'showEntry' not found or invalid function name in /home/mysite/public_html/wp-includes/plugin.php on line 406      can anybody please tell me why this is showing and how to solve this? ok..i found out there this is related to a plugin. but i don't know the reason. please help me to find the reason why this is showing. the plugin part that contains this function is listed below: the plugin name is clinic clinic.php               add_action('admin_print_scripts', 'showEntry');      appointment-book.php               <select name="eemail_subject_drop" id="eemail_subject_drop" onchange="showEntry(this.value)">                     <option value="">Select Email template</option>       <?php echo $eemail_subject_drop_val; ?>                 </select>      settings.js               function showEntry(id)     {                jQuery(document).ready(function($) {          var data = {         action: 'template_action',         id: id          };          // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php     jQuery.post(ajaxurl, data, function(response) {         //alert('Got this from the server: ' + response);          jQuery('textarea#mail_contents').text(response);          });          });         }      view-subscriber.php               <select name="eemail_subject_drop" id="eemail_subject_drop" onchange="showEntry(this.value)">                     <option value="">Select Email template</option>                     <?php echo $eemail_subject_drop_val; ?>                 </select>      what is the error in these files. this warning happens when the site is moved to a new server with cpanel. please help me to solve this.


title: Starter Theme vs Parent Theme? Pros and cons

text: I'm building a theme to be used as an example for other websites for the company I'm working. In another project we used the Hybrid Parent Theme and was really easy to build, but REALLY hard to maintain the website. I prefer the Starter Theme approach, which another developer copy the theme and create from it. The Parent->Child gives too much freedom for the developer mess the code. For example I didn't know if something was being called on the child or on the parent. I would like to hear from you:   * When a Parent theme is better?    * When a Starter Theme is better?    * What are the pros and cons for each of them? Thanks.


title: How to adjust the Cartpress e-commerce plugin?

text: Has anyone used Cartpress before that could give me some pointers? I've installed the plugin but struggling to find all the templates it uses to display everything. I'm using the default theme in WP and have set everything up in that. Things I want to include are:   1. Display 3 top products on the homepage.   2. Adjust the look of how all the products are displayed.   3. Tailor the look of checkout process.   4. Display a basket. I've tried using Dukapress and wpStoreCart but Cartpress seems the easiest to adjust. It's easy enough to change to a different plugin as I'm only just starting out.


title: I want to remove top admin bar from wordpress. How to?

text: whenever admin or any other user logs in a top bar menu ads up. Now I made login for everybody, so I do not want this bar. first I added display:none to admin-bar.css, but the main problem is that wordpress is still adding a white line on the top with: html { margin-top: 28px !important; } how to remove this as this is causing some design flaws. Thanks!


title: WordPress 3.2.1: jQuery is not defined, breaks Admin panel

text: I've fresh-installed a WordPress 3.2.1 on my server yesterday. Unfortunately, installing 3.2.1 breaks all the jQuery scripts and I can't click on "Collapse menu", "HTML" in the editor, "Fullscreen" - basically, everything that's loaded with jQuery. I've tested with Safari, Firefox and Chrome on a MAC OS X. I downgraded on 3.2.0 and jQuery is working properly on this version, but when I upgrade back to 3.2.1. everything breaks. If you think it's related to JSON, JSON is working properly with PHP, too. I also don't have any plugins installed, except Akismet and the theme installed with the default one: Tweenty Twelve or smtg. Can anyone help me? Thank you.


title: use of 10 new WP_Query : loading too slow (with url)

text:
i use almost 10 new WP_Query() in my main page, but the loading is quite slow : do you know what i could do for that? each "new WP_Query()" ends up with a "endwhile" : is that enough? is there anything like reset query possible with WP_Query() ? you can check my website here : www.pondb.com : it's not finished (and some of the text is missing) but you can see the time to load it, and the source code. edit: some code from the index.php : (i might erase 1 or 2 queries, but the load time is still like 10 seconds on my computer...)

                 Contact                      <?php $my_query = new WP_Query('category_name=bio');                 while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php echo get_the_title(); ?>

<?php the_content(); ?>
                  <?php endwhile; ?>

News
                 <?php query_posts('category_name=news&showposts=3'); ?>                  <?php while (have_posts()) : the_post(); ?>
<?php echo the_title(); ?>

Posté le <?php echo the_time('j F, Y'); ?>

<?php the_excerpt(); ?>
                 <?php endwhile; ?>                 <?php wp_reset_query(); ?>
                     Lire les news

             Contact             <?php             $my_query = new WP_Query('category_name=news&showposts=8');             while ($my_query->have_posts()) : $my_query->the_post(); ?>              <?php $category = get_the_category();                 if ($category[0]->cat_name <> $sav_category){                     echo "
".$category[0]->cat_name.":
";                     $sav_category = $category[0]->cat_name;                 }?>

<?php echo get_the_title(); ?>

Posté le <?php echo the_time('j F, Y'); ?>

<?php the_content(); ?>

                      <?php endwhile; ?>

             <?php $my_query = new WP_Query('category_name=concert');             while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php echo get_the_title(); ?>

<?php the_content(); ?>
              <?php endwhile; ?>

      Thanks for your help


title: Wordpress - thumbnail image from youtube (function and loop)

text: Hi :D i need show thumbnails from youtube in homepage, i have a code for wordpress in function and the loop but not working thumbnail from youtube. What can be wrong with the code? Function Code:                 function get_thumbnail_fromyoutube( $size = 0 ) {           global $post, $posts;           $youtube = '';           $get_url = preg_match_all('//i', $post->post_content, $matches);           $youtube = $matches[1][0];           if(preg_match('/^(http:\/\/www.youtube.com)/', $youtube))           {             $youtube = preg_replace('/(.*?).embed\//', '', $youtube);             $youtube = preg_replace('/\?.(.*?)$/', '', $youtube);             echo 'post_title . '" />';           }              }      LOOP CODE:               <?php     $args = array(         'tax_query' => array(             array(                 'posts_per_page' => 1,                 'order' => 'DESC',                 'taxonomy' => 'section',                 'field' => 'slug',                 'terms' => 'video'                       )         )     );     $query = new WP_Query( $args );     if ( $query->have_posts() ) {         while ( $query->have_posts() ) {             $query->the_post();                   ?>               <img src="<?php echo has_post_thumbnail() ? the_post_thumbnail('thumbnail') : get_thumbnail_fromyoutube(); ?>" alt="<?php the_title(); ?>"/>     <?php                                  }                           }                              wp_reset_query();  // Restore global post data stomped by the_post().                         ?>


title: wp_tiny_mce function not found

text: I am trying to add the embedded TinyMCE editor to content area using the code:               add_action( 'comment_form_after', 'tinyMCE_comment_form' );          function tinyMCE_comment_form() {              wp_tiny_mce(false, array(             'mode' => 'exact',             'elements' => 'comment',             'height' => 200,             'plugins' => 'inlinepopups,wpdialogs,wplink,media,wpeditimage,wpgallery,paste,tabfocus',             'forced_root_block' => false,             'force_br_newlines' => true,             'force_p_newlines' => false,             'convert_newlines_to_brs' => true         ));          }      defined in **functions.php** of my theme. For some reason if I load a page with comments there it returns the error **wp_tiny_mce is not found**. Do you know how to fix it? Maybe I chosen the wrong action?


title: Swatch Internet Time for article timestamps

text: The date and time when the article was published is shown below the article title. How do I show Swatch Internet Time there instead of local time?


title: Custom taxonomy not appearing in menu administration panel

text: I am unable to see custom taxonomy box in the wordpress new menu system. I can see the post types but custom taxonomies are not available. I saw the screen options aswell custom taxonomies are not listed there. I am using more taxonomy plugin to create taxonomy.


title: Getting the WordPress custom menu titles and outputting them in a theme

text: I have created a number of custom menu slots in my WordPress theme, and the output of the links into them has been very easy. Unfortunately I cannot find a way to output the _user entered_ title for the menu above the list in each menu slot. This doesn't seem to come with the default WordPress function. I am wondering if there is a simple and efficient way to grab the user entered name of the menu that is currently in a slot in my theme. [Somewhat like the way the widgets function allows you to chose whether you want to show the title of the specific widget.] Thanks in advance. **EDIT: Still looking for help!**


title: Different post sort order within different categories

text: I need to give _each_ post a _unique_ post order for multiple Categories (per post) it is in. I can imagine a solution using custom fields whereby for each Category there is a corresponding custom field for the order. E.g. Categories: Playlist1 Playlist2 Playlist3 Custom fields for the post: Playlist1_Order Playlist2_Order Playlist3_Order This method is obviously not easily scalable though so I would like to know if anybody has a more elegant solution. ## Background I am setting up a site to accompany a 24/7 broadcast. The playlist for the broadcast is a 12hr loop that is modified once per week. **Some shows are added & removed and the order of some shows is re-arranged.** I intend to define a custom post type of Shows and custom taxonomy of playlist. **Each show will be added to one or more playlists. It must be possible for the show to have a unique order in each playlist.** (I decided to keep the question limited to posts & categories rather than post-types & taxonomies to avoid confusion). ## UPDATE To clarify, consider this example. There's a post called "Rod's Radio Roundup." It's in the categories "Tuesday Lineup" and "Wednesday Lineup." On Tuesday it's the third show and Wednesday it's the 7th show. Later, it leaves Wednesday but moves to the 1st slot on Thursday and the 5th slot on Saturday. And there are 40 other posts like this. The essential question: How do you maintain multiple orders, one per category, for a single post?


title: wp_ajax_nopriv_xxx is not firing on one site, works on all others. -1 for logged out users

text: my plugin uses add_action for `wp_ajax_cl_ajax` and `wp_ajax_nopriv_cl_ajax` in it's code and on the few thousand sites that are using it, it is fine but one site is not working for logged out users a logged in user is fine, the code sends a request to ajax and everything gets returned fine. on other blogs, a logged out user is fine but just on this one blog a -1 gets returned for the ajax request. I have added debug code to the plugin to die at the do_ajax function with a message but it doesn't even get to that function. here's the action for the logged out user ajax `add_action('wp_ajax_nopriv_cl_ajax','do_ajax');` the function has this               function do_ajax(){         if(isset($_REQUEST['debug'])){           die('in ajax function');        }     }      I just change the ajax url to have a var for debug (..../wp-admin/admin- ajax.php?debug=true) on my test sites it dies, for a logged in user it dies but for a logged out user, it just returns -1 which tells me the action is not even being triggered. I added more debug code to the function that adds the actions for `has_filter` and it returns 1 so i know the action is added, just not fired. I've tried changing the theme but no joy there the site is using wp 3.2 does anyone have any experience with wp_ajax_nopriv_xxx not firing? what caused it for you? as I said, it is working fine on other blogs so I know it isn't a case of a typo or missing code. what other things can I do to determine what is causing the action not to fire?


title: SQL query add only posts with custom field to array

text: I have this SQL query which is building an array of wordpress posts...               $query = "select $wpdb->posts.* from $wpdb->posts,$wpdb->terms,$wpdb->term_taxonomy,$wpdb->term_relationships where $wpdb->terms.term_id in (".$catId.") and $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id and $wpdb->term_taxonomy.taxonomy = 'pcategory' and $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id AND $wpdb->posts.post_status = 'publish' and $wpdb->term_relationships.object_id = $wpdb->posts.ID and $wpdb->posts.ID != ".$post->ID." group by $wpdb->posts.ID order by $wpdb->posts.ID LIMIT 0 ,$limit";      I need to modify this to allow me to add a condition that only posts with a specific custom field value, say 'Apple' are included in the array. Can anyone point me in the right direction? ## UPDATE I have tried to modify it to this....               $query = "select $wpdb->posts.* from $wpdb->posts,$wpdb->terms,$wpdb->term_taxonomy,$wpdb->term_relationships where $wpdb->terms.term_id in (".$catId.") and $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id and $wpdb->term_taxonomy.taxonomy = 'pcategory' and $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id AND $wpdb->posts.post_status = 'publish' and $wpdb->postmeta.meta_key = 'fruit' and $wpdb->postmeta.meta_value= 'apple' and $wpdb->term_relationships.object_id = $wpdb->posts.ID and $wpdb->posts.ID != ".$post->ID." group by $wpdb->posts.ID order by $wpdb->posts.ID LIMIT 0 ,$limit";      I was assuming that this would narrow down the search to only the posts that have a value of 'apple' for the custom field named 'fruit' but its not working


title: Using AJAX to run sql statement and populate dropdown

text:
I am trying to create a search where the user select two different bit of data from databases and it them prints some results that meet requirements. I know I need to use ajax or something similar but I have little idea how I should be doing it. The first drop down box works fine as that doesn't depend on anything here is the code for that.               <select name="raceTrack2" onchange="">                 <?php                 $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");                      foreach ($postids as $value) {                     echo '<option>' . $value . '</option>' ;                      }                 ?>             </select>      That works fine now the next step I need to do is where it start to get complicated I need to take the value of the first selection box and add it into the sql query of the next one then run that query when the first selection box changes using onchange.               <select name="raceDate">             <?php                  $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate FROM " . $tableName . " WHERE trackName = '" . $track . "';");                      foreach ($postids2 as $value2) {                     echo  $value2  ;                         }                 ?>             </select>         Then I need to take the value of both of these dropdowns and use it in this final query to display the results.               $postids = $wpdb->get_results("SELECT driverName, driverClass, driverPosition FROM " . $tableName . "WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";");                      foreach ($postids as $value) {                     echo '
';                     echo '' . $value->driverName . '	';                     echo '' . $value->driverClass . '	';                     echo '' . $value->driverPosition . '	';                      echo '
';                 }                   }      Any suggestions would be appreciated.


title: Change the class of wordpress menu

text: I have problems with wordpress menu level classes.               <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>      this is the code i used to generate my menu, First level menu id is > ul id="menu-home" second level class is > ul class="sub-menu" but my third level menu also has same class as second level > ul class="sub-menu" is there any way to change the class of third level or some other solution??? please help.. thankyou


title: Have different search results template depending of custom post type searched

text: I have a site with different custom post types, I have two "index pages" for each one of these (where I query the posts and show) and also I include a search form on both of them. So the thing is that search forms goes by default to the search.php template, to filter search and show results only for that custom post type I'm using a hidden field on form: `<input type="hidden" name="post_type" value="staff" />` but then on the search I'd like to provide a "back" link to allow the user to go back to the index page, the thing is that I can't find an if statement that works to show different "back to" links depending of the custom post type searched. Example: If I search for News then I'd like to have a back to News index button If the search is on Staff the button shown has to be back to Staff index. I appreciate any help guys!   Thanks!   Juan.


title: Unschedule a post

text: I have some posts scheduled for tomorrow. I want instead to remove the scheduled date and simply publish them manually when I am ready. I can't find anything about this. Does just setting them to "Draft" accomplish this? When I change the status from "scheduled" to "draft", the date remains.


title: Adding Tag On Single Post from bbpress (Tewenty Ten) Themes

text: i want adding tag on my single post, currently now i am using bbpress (Twent Ten) Themes, What i want is include Taged With : on a single post. Thank You, RA


title: custom cron interval is not working

text: I am trying to create custom interval for cron schedule with below code but it is not working,               function cronschedules($schedules) {     $schedules['custom'] = array(     'interval' => 36000, // seconds        'display'  => __('Custom Interval')              );       return $schedules;      }     add_filter('cron_schedules', 'cronschedules');     wp_schedule_event(time(),'custom','ACPdailyevent');      here is the debug log:               [15-Apr-2014 12:02:12 UTC] PHP Notice:  Undefined index: custom in C:\wamp\www\wp\wp-includes\cron.php on line 111          [15-Apr-2014 12:02:12 UTC] PHP Stack trace:          [15-Apr-2014 12:02:12 UTC] PHP   1. {main}() C:\wamp\www\wp\wp-cron.php:0          [15-Apr-2014 12:02:12 UTC] PHP   2. call_user_func_array() C:\wamp\www\wp\wp-cron.php:87          [15-Apr-2014 12:02:12 UTC] PHP   3. wp_reschedule_event() C:\wamp\www\wp\wp-cron.php:87


title: How to call a plugin function from index.php

text: I have created a function in my plugin `myplugin` with the name `foo`, how to call it from the frontend?                e.g. index.php?


title: How to enable commenting system in Wordpress

text:
I am learning how to create custom Wordpress theme from this page   and everything is working except commenting system because they haven't described how to enable it (they only used `<?php comment_form(); ?>` to insert form into template). I can see my comment in the backend but not in the page itself (I can see a link showing **1 comment** but when I click it nothing happens). Obviously I need some PHP code to show my comments but have no idea where to start! I am stuck because I just started to learn Theme Development and my PHP knowledge is limited.   Can anyone give me a suggestion or a solution for that problem? It would a mean a lot to me. Index php looks like this:               <?php get_header(); ?>
         <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                  <?php the_post_thumbnail(); ?>                 <?php the_content(); ?>
                 <?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
                 <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

              <?php endwhile; ?>
         <?php posts_nav_link(); ?>
              <?php endif; ?>
         My Wordpress page HERE   Thank You!!