title: Loop within a loop?

text:
I'm using a couple of custom wp_query loops on my page, the first one retrieves news from a certain category then displays a small excerpt from it with the permalink. The second one is another wp_query that gets a custom post type with a few advanced custom fields. The problem is I'd like another loop within the second one that gets 3 posts from the news section with a thumbnail (basically the opposite of the first loop, it'll get all the other categories). After reading countless articles on the loop I can't figure out how to make a 'nested' loop within my second loop. I'm sure it's got to be simple, seems like something that'd be easy to do. Here's my code with a lot of html stripped out.               <?php                /*         Template Name: Homepage     */          ?>          <?php get_header(); ?>

latest news

                      <?php                             $recentPosts = new WP_Query();                             $recentPosts->query('cat=5&showposts=1');                         ?>                 <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<?php echo ''.get_the_twitter_excerpt(); ?>...

                          <a href="<?php the_permalink() ?>">Read it                               <?php endwhile; wp_reset_query(); ?>

                          <?php     $portfolio_query = new WP_Query(array(             'post_type' => 'headerhome',             'showposts' => 1             ) );     ?>                     <?php while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?>
<?php the_title(); ?>
                           <?php the_content(); ?>

 <?php the_field('anyresolution'); ?>

<?php the_field('services_'); ?>

 <?php the_field('services_text'); ?>

 <?php the_field('services_text_right'); ?>

<?php the_field('services_1_header') ?>

<?php the_field('services_1_content'); ?>

<?php the_field('services_2_header') ?>

<?php the_field('services_2_content'); ?>

<?php the_field('services_3_header') ?>

<?php the_field('services_3_content'); ?>

<?php the_field('gallery_blockquote_') ?>

<?php the_field('gallery_content'); ?>
              <?php endwhile; wp_reset_query(); ?>
                                                             <?php get_footer(); ?>      Working code, though it won't retrieve the_post_thumbnail               <?php                                 global $post;$backup=$post;                                 $inner_query = new WP_Query();                                 $inner_query->query('showposts=3');                             ?>                                  <?php while ($inner_query->have_posts()) : $inner_query->the_post(); $post=$backup; ?>                                                 <?php the_post_thumbnail(); ?>
<?php echo ''.get_the_custom_excerpt(); ?>...
                              <a href="<?php the_permalink() ?>">Read it                                        <?php endwhile; ?>


title: List products from current category

text: This code is from the archive page and list all products with a certain tag, can someone please help me to modify this code to make listing products only from current category:               <?php if ( is_product_tag() ) :?>            <?php do_action('woocommerce_before_shop_loop'); ?>             <ul class="products">                 <?php while ( have_posts() ) : the_post(); ?>                     <?php woocommerce_get_template_part( 'content', 'product'); ?>                 <?php endwhile; // end of the loop. ?>             </ul>         <?php do_action('woocommerce_after_shop_loop'); ?>     <?php endif; ?>


title: WordPress Network on IIS7/SQL Server - Rewrite Issues

text: I've just installed a fresh WordPress setup on Windows Server 2008 Web R2 (IIS7) with SQL Server Express and WordPress 3.1. I completed the install successfully and logged into the admin section to start the activation of the WordPress network (using sub-domains). Having edited the wp-config file, I added the code WordPress generated to both wp- config (Network specific) and web.config (Rewrites). Since adding these changes, each time I try to login to WordPress, I just get loop'd straight back to the login page. I've tried to following so far:   1. Comment out the network specific changes in wp-config and revert the rewrite rules to standard WordPress ones (Didn't work).   2. Checked IIS Admin for any re-writes already in place (None) Details of wp-config and web.config below:               wp-config:     define('WP_ALLOW_MULTISITE', true);          define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', true );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'svr-web-csrms' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      web.config: http://pastebin.com/8xctXizE Update: I have had a thought. From reading this here: > Note that per the Settings Requirements you cannot switch from Sub-folder to > Sub-domain >when running on 127.0.0.1 or localhost. This can potentially > cause an endless loop of >reauth=1 on your root site due to cookie handling. I may have an issue due to the fact I am using an internal address. I'll set WordPress up with a proper domain and come back.


title: Show All Children of WordPress Menu

text: The code below shows the active sub menu of the Main Menu. It's nearly perfect, however, I need it to show ALL subitems of these sub items, and their children. AKA unlimited depth. Thanks in advance! To further clarify here is an example: WP - Main Menu   1. Home   2. About   3. News (Active Menu Item)      * Press     * Social        * Facebook       * Twitter     * Speeches   4. Contact With the code currently, if I'm on News, Press, Social, Facebook, or Twitter Page, it shows the side menu:   1. Press   2. Social   3. Speeches That is what I want, except that on all of those pages, "Social"'s two children (Facebook and Twitter should appear under social as well.               class Selective_Walker extends Walker_Nav_Menu         {             function walk( $elements, $max_depth) {                      $args = array_slice(func_get_args(), 2);                 $output = '';                      if ($max_depth < -1) //invalid parameter                     return $output;                      if (empty($elements)) //nothing to walk                     return $output;                      $id_field = $this->db_fields['id'];                 $parent_field = $this->db_fields['parent'];                      // flat display                 if ( -1 == $max_depth ) {                     $empty_array = array();                     foreach ( $elements as $e )                         $this->display_element( $e, $empty_array, 1, 0, $args, $output );                     return $output;                 }                      /*                  * need to display in hierarchical order                  * separate elements into two buckets: top level and children elements                  * children_elements is two dimensional array, eg.                  * children_elements[10][] contains all sub-elements whose parent is 10.                  */                 $top_level_elements = array();                 $children_elements  = array();                 foreach ( $elements as $e) {                     if ( 0 == $e->$parent_field )                         $top_level_elements[] = $e;                     else                         $children_elements[ $e->$parent_field ][] = $e;                 }                      /*                  * when none of the elements is top level                  * assume the first one must be root of the sub elements                  */                 if ( empty($top_level_elements) ) {                          $first = array_slice( $elements, 0, 1 );                     $root = $first[0];                          $top_level_elements = array();                     $children_elements  = array();                     foreach ( $elements as $e) {                         if ( $root->$parent_field == $e->$parent_field )                             $top_level_elements[] = $e;                         else                             $children_elements[ $e->$parent_field ][] = $e;                     }                 }                      $current_element_markers = array( 'current-menu-item', 'current-menu-parent', 'current-menu-ancestor' );  //added by continent7                 foreach ( $top_level_elements as $e ){  //changed by continent7                     // descend only on current tree                     $descend_test = array_intersect( $current_element_markers, $e->classes );                     if ( !empty( $descend_test ) )                          $this->display_element( $e, $children_elements, 0, 0, $args, $output );                 }                      /*                  * if we are displaying all levels, and remaining children_elements is not empty,                  * then we got orphans, which should be displayed regardless                  */                  /* removed by continent7                 if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {                     $empty_array = array();                     foreach ( $children_elements as $orphans )                         foreach( $orphans as $op )                             $this->display_element( $op, $empty_array, 1, 0, $args, $output );                  }                 */          /*added by alpguneysel  */                     $pos = strpos($output, '<a');                 $pos2 = strpos($output, 'a>');                 $topper= substr($output, 0, $pos).substr($output, $pos2+2);                 $pos3 = strpos($topper, '>');                 $lasst=substr($topper, $pos3+1);                 $submenu= substr($lasst, 0, -6);                  return $submenu;             }         }


title: Will there be security updates for 3.1 once 3.2 is released?

text: I am currently running WordPress 3.1.2 on PHP 5.1.6. The minimum requirement for WordPress 3.2 is going to be PHP 5.2.4 or greater. If I keep running WordPress 3.1.2 and there is a security issue will they provide security updates for 3.1 or will I be forced to upgrade my version of PHP so that I can upgrade to WordPress 3.2?


title: How to add featured images to posts from a category

text: i'm using an rss to post plugin. The posts fetches from the RSS do not have any pictures associated with them. Is there a way to automatically assign a 'featured image' to posts from a category? Another option is that in my WP theme, with the custom field as 'thumb' I can add images/reuse same images.. is there a way to make use of this and assign a default pic to all posts from a category? Edit: Based on Martin's suggestion I installed the get image plugin. The code mentioned in the read me is this:               get_the_image( array( 'default_image' => 'http://www.mydomain.com/wp-content/uploads/defaultimage.png' ) );      However, my theme isn't that direct. It makes use of a function in the functions.php file.               // Get image attachment (sizes: thumbnail, medium, full)     function get_thumbnail($postid=0, $size='full') {         if ($postid<1)          $postid = get_the_ID();         $thumb_key = get_theme_mod('thumb_key');         if($thumb_key)             $thumb_key = $thumb_key;         else             $thumb_key = 'thumb';         $thumb = get_post_meta($postid, $thumb_key, TRUE); // Declare the custom field for the image         if ($thumb != null or $thumb != '') {             return $thumb;          } elseif ($images = get_children(array(             'post_parent' => $postid,             'post_type' => 'attachment',             'numberposts' => '1',             'post_mime_type' => 'image', ))) {             foreach($images as $image) {                 $thumbnail=wp_get_attachment_image_src($image->ID, $size);                 return $thumbnail[0];              }         } else {             return get_bloginfo ( 'stylesheet_directory' ).'/images/default_thumb.gif';         }          }          // Automatically display/resize thumbnail     function tj_thumbnail($width, $height) {         echo 'ID).'" rel="bookmark">ID, 'full').'&h='.$height.'&w='.$width.'&zc=1" alt="'.get_the_title().'" />';     }      I need help in adding the get_the_image function into the one above so it checks.. If category id=120, then display mydefaultimage.png else, do the regular thing. Thanks.


title: WordPress Theme activation hook?

text: I know the many tricks to see if said theme is activated, I have scoured the internet. I am not looking for re-pasting of that code. What I am looking for though is weather or not 3.3-3.5 released a new function that does something upon theme_init, I saw some sort of hook, but I can't remember where, in the codex, dealing with doing things after a theme has been initialized.. Any one know?


title: Do I need an empty page for a different blog page?

text: Okay, let's say I have a website with the following navigation: HOME - ABOUT - PRODUCT - NEWS - CONTACT The 'about' and 'contact' page are just simple pages of course. The 'product' page is just an archive of a custom post type. Nothing special over there. Then there's just the 'home' and 'news' page. If I make a page called 'home', I can than go to 'Settings' > 'Reading' and set a static page as front page. But now I would like the 'news' page to be the 'default' posts overview. But somehow, I've never found a way to make this work without creating an empty paged called 'news' or something and go to 'Settings' > 'Reading' again, and set this page as the posts page. But now I have an empty page inside the pages overview, and I don't really want that page. Clients try to put stuff in there and email me that it doesn't show up and stuff like that. So question is, do you really need to create an empty page just to set that page as the posts page/blog page?


title: How can I add a new bulk action to the bulk action dropdown field in the comments interface

text: > **Possible Duplicate:**   >  Custom bulk_action As the title suggests I would like to add a new bulk action to the bulk action dropdown field in the comments interface. Specifically, I would like to add a CSS class to specific comments on the front end by marking comments with this new bulk action.


title: Translation of theme using child theme

text: I have created a folder called “languages” in my child theme directory and added a: da_DK.po and a da_DK.mo file generated using POedit. I have created a functions.php file in my child theme directory and added the following lines of code (as guided here: http://codex.wordpress.org/Child_Themes):               <?php          /**     * Setup My Child Theme’s textdomain.     *     * Declare textdomain for this child theme.     * Translations can be filed in the /languages/ directory.     */     function my_child_theme_setup() {     load_child_theme_textdomain( ‘ifeaturepro5-child’, get_stylesheet_directory() . ‘/languages’ );     }     add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ );     ?>      This causes two issues: ### 1\. I cannot log into my wordpress admin area ### 2\. Trying to add a comment front end causes an error or a blank page. When deleting the custom functions.php file in the child theme directory everything turn back to normal. What have I entered wrong in my custom functions.php file shown above?


title: How does Wordpress know if a revision can be restored?

text: I'm looking at the wp-admin/revisions.php and I'm confused about this block of code:               <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>                 <input  <?php if ( wp_check_post_lock( $post->ID ) ) { ?>                     disabled="disabled"                 <?php } else { ?>                     <# if ( data.attributes.current ) { #>                         disabled="disabled"                     <# } #>      I unnderstand if the WP_check_post_lock() checks if another user is editing a post and locks the button 'Restore this Revision' in the browse revisions page. I don't understand the second part. What is data.attributes.current? I'm writing a plugin that adds a revision to the database but the user is not able to click on the button to restore the most current revision because it's adding that disabled="disabled" attribute to the button. Any help would be appreciated!


title: MySQL Query To Select Post By Postmeta

text: I have two custom post types, _type1_ and _type2_. _Type2_ posts have a postmeta called _postID_ that is the ID number of a post in _type1_. When showing _type1_ in single.php I want a mysql query that selects the _type2_ post. The only data I have is the ID number of _type1_. So I have to select from _type2_ postmeta where the meta_key = postID and the meta_value = _type1_ ID. I then need to use the post_id of that row to select the post from wp_posts. I'm not good with forming mysql queries, so is there a single query that will do this?


title: Most Effective Method? Exclude Category and Number of Posts Per Page

text: I want to create a loop that excludes a category and only displays a certain number of posts per page. I have tried both have_posts and query_posts to do this, but I'm a bit stuck on the most effective method. What would you use to do this?


title: Loop Offset for tag based "Related Posts"

text:
As I'm using the jQuery Tool "Scrollable" for my Related Posts section (see example here), I was wondering how I can implement an offset so that in the first loop it'll show the first 4 posts, then the next 4 related posts etc. I'm thinking about creating 3 loops like that right now, displaying the latest 12 related posts overall. My current setup looks like this: (updated!)
Related Posts

                                           <?php                                  $backup = $post;                                 $tags = wp_get_post_tags($post->ID);                                 if ($tags) {                                     $tag_ids = array();                                     foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;                                          $args = array(         'tag__in' => $tag_ids,         'post__not_in' => array($post->ID),         'posts_per_page'=> 12     );                                          $my_query = new WP_Query( $args );     if( $my_query->have_posts() ):     ?>
                <?php         while ( $my_query->have_posts() ) : $my_query->the_post();                  the_title();                  // if this is not the last post             // and remainder of current post plus one then divided by four is zero             // close the container and open a new one             if( $my_query->current_post != ( $my_query->post_count - 1 ) && ( ( $my_query->current_post + 1 ) % 4 ) == 0 ):                 ?>

       <?php             endif;            endwhile;         ?>

      However, I just don't know how to implement it into the existing code. Not sure if that's even possible or if I first have to use a different way to create my loop to make it work? Thanks a lot in advance! :) **EDIT: Last updated on October 16th. I still haven't figured this out, please help!**


title: How to prevent options.php deleting valid existing data from the database

text: I am setting up a plugin and have used the setting API for the first time to create a form in settings. The data for the plugin is initially created by default when the plugin is activated and stored in the database in a serialized format. Today I added the validation callback function, which works fine to do validation. However when any field fails validation and the function returns false (I have also tried returning NULL) the existing valid data in the database is deleted. Question is this how things are supposed to happen or am I doing something stupid? I would have expected in this situation that the existing valid data in the database would have remained unaltered until such time as the user had presented a set of valid data to alter it. Any suggestions appreciated.


title: How to add pagination with page numbers rather than next/previous links?

text: Does WordPress have any built-in pagination functions to show the page numbers instead of previous and next page links? If not, how can I add that? Thanks


title: Recent posts on homepage

text:
I have made a page where you people can find al the teasers (teaser made with the read more tag) from my posts.( By clicking one of them you "open" the whole article, including photo's, ... . This is working well. On my homepage I want a short welcome text and in a sidebar my 3 recent posts. I'm first trying to get the recent posts on my homepage with following code               <?php     function recentPosts() {         $rPosts = new WP_Query();         $rPosts->query('showposts=3');             while ($rPosts->have_posts()) : $rPosts->the_post(); ?>                          <a href="<?php the_permalink();?>"><?php the_post_thumbnail('recent-thumbnails'); ?>
<a href="<?php the_permalink(); ?>"><?php the_title();?>
                     <?php the_content(); ?>                  <?php endwhile;          wp_reset_query();     }     ?>      This is working well but on my homepage I'm getting all the content from my articles and I only want a teaser. (2 lines for example). I don't know how to do this here. Below you see the code of the home page.               <?php     /**      * @content not visible      * @content not visible      *      * Template Name: homepage      */     ?>     <?php get_header(); ?>     <?php echo recentPosts(); ?>     <?php the_content(); ?>     <?php get_footer(); ?>


title: How to list all record from one custom taxonomy start with only one letter i.e A

text:
I want to list all records in one custom taxonomy start with only A or B. Below code is to list all record with all letters. Here is the code to list all record with one custom taxonomy with all letters in groups. Example, ![enter image description here](http://i.stack.imgur.com/Q52Cx.png)               <?php      // Template Name: Store Template               // get all the stores     $stores = get_terms(APP_TAX_STORE, array('hide_empty' => 0, 'child_of' => 0, 'pad_counts' => 0, 'app_pad_counts' => 1));     // get ids of all hidden stores      $hidden_stores = clpr_hidden_stores();     $list = '';     $groups = array();               if ($stores && is_array($stores) ) {              // unset child stores         foreach($stores as $key => $value)         if($value->parent != 0)               unset($stores[$key]);              foreach($stores as $store)             $groups[mb_strtoupper(mb_substr($store->name, 0, 1))][] = $store;              if (!empty($groups)) :                  foreach($groups as $letter => $stores) {           $old_list = $list;           $letter_items = false;                 $list .= "\n\t" . '
' . apply_filters( 'the_title', $letter ) . '
';                 $list .= "\n\t" . '
';                      foreach($stores as $store) {                     if (!in_array($store->term_id, $hidden_stores)) {                         $list .= "\n\t\t" . '
' . apply_filters('the_title', $store->name). ' (' . intval($store->count) . ')
';               $letter_items = true;             }                 }                         $list .= "\n\t" . '
';                if(!$letter_items)             $list = $old_list;             }              endif;          } else {              $list .= "\n\t" . '
' . __('Sorry, but no stores were found.', 'appthemes') .'
';          }     ?>


title: Specify number of posts in my 'tax_query'

text: I'm showing posts of the term 'football' belonging to the taxonomy 'section', and everything works perfectly but Where can I specify the number of posts I want to show? just like this: 'showposts' => 3 I do not know where to put it                   $myquery['tax_query'] = array(                        array(                             'taxonomy' => 'section',                             'terms' => array('futbol'),                             'field' => 'slug',                         ),             );             query_posts($myquery);


title: changing default comment form arguments

text: I want to change the default comment form title_reply, label_submit ... just on my CPT without affecting the default comment form but I can't get it to work without affecting the default ones. **First** I don't want to output the comment form if CPT and user isn't logged in, I'm doing this with this code:               // Don't output the comment form if CPT and user isn't logged in     if ( 'myCPT' != get_post_type() || is_user_logged_in() ) {      comment_form(array('title_reply'=>'Got Something To Say:'));      }      Which is working fine, but I want also to check if CPT exists and alter the default comment form if I'm inside that CPT. Now the question will be how can I put this together ? Thank you!


title: strange conditional tag behaviour

text:
I have this code inside my comments.php :               <?php      // If CPT and not logged in, display a message:      if ( 'CPT' == get_post_type() && ! is_user_logged_in() ) {      echo '
You must be logged in to post a comment.' . '
';           echo do_shortcode("[upme_login]");           }      ?>      and this code :                  <?php      // Don't output the comment form if CPT and user isn't logged in            if ( 'CPT' != get_post_type() || ! array_key_exists( 'comments', $wp_query->query_vars ) ) {           comment_form();      }           ?>      When the user is not logged in it should display a message like **You must be logged in....** which is doing, **but** I see the comment form also which normally I shouldn't see it. If I remove this `|| ! array_key_exists( 'comments', $wp_query->query_vars )` everything is working as expected. How can I do to make it visible if the user is logged in? What is wrong?


title: Combining the_excerpt with the_content

text:
I have some html:

The first paragraph...

The rest of the article...

      I'd like to put "the_excerpt" in the first paragraph (with a special colour / font size) but then have the following text be "normal". Is there a way to **subtract** the_excerpt from the_content so the section "The rest of the article" does not repeat the excerpt?


title: Adding a comment link to the top of every post

text: By default, all of the posts on our Wordpress install have a post comment link at the bottom of the post. How can we add one at the top?


title: How to include a file only on dashboard widgets page?

text: I want to add some styles to the widgets input fields. Therefore I want to include a style.css file only on the `wp-admin/widgets.php` page. How can I detect the above page and include file there?


title: Rewrite rules for custom post type with another custom post as post parent

text: I have 2 hierarchical custom post types sale and lot. Each lot belongs to a single sale (the sale ID is used in post_parent. I need URLs like website.com/sale/sale_name/lot/lot_name. So far I have website.com/lot/sale_name/post_name which gives a 404. Please help


title: Custom fields setup when category selected filter subcategories

text:
Hi all I have custom taxonomies and custom user input fields for submiting their classifieds. So what I was intending to do is: users should select category, I want to make it able when user select a category to show him in next select box field subcategories of that category. So, if user select, car model>audi to automaticly open below select field is that audi> a3, a4, a5 or other. I hope I was explained that pretty well. Here is my custom field "category.php"                   <?php         global $wpdb,$post;         wp_reset_query();         $template_post_type = get_post_meta($post->ID,'submit_post_type',true);         $custom_post_types_args = array();               $custom_post_types = get_post_types($custom_post_types_args,'objects');                  global $post;                  foreach ($custom_post_types as $content_type){                      if($content_type->name == $template_post_type)                 {                     $taxonomy =  $content_type->slugs[0];                     if($content_type->name =='post' || strtolower($content_type->name) ==strtolower('posts')){                          $taxonomy='category';                     }                 }             }         $catinfo = templ_get_parent_categories($taxonomy);         if(count($catinfo) == 0)         {             echo ''.sprintf(__('You have not created any category for %s post type.So, this listing will be submited as uncategorized.',DOMAIN),$template_post_type).'';         }         global $cat_array;         $total_cp_price = 0;         if(isset($_REQUEST['backandedit']) != '' || (isset($_REQUEST['pid']) && $_REQUEST['pid']!="") ){             $place_cat_arr = $cat_array;         }         else         {             for($i=0; $i < count($cat_array); $i++){                 $place_cat_arr[] = @$cat_array[$i]->term_taxonomy_id;             }         }         $cat_display = "";         $tmpdata = get_option('templatic_settings');         if(isset($tmpdata['templatic-category_type']) && $tmpdata['templatic-category_type'] != "")          {             $cat_display = $tmpdata['templatic-category_type'];          }         if(!$cat_display)           {             $cat_display = 'checkbox';           }         /* Start of checkbox */         if($cat_display == 'checkbox')         {             if($catinfo) {                 if($cat_display==''){ $cat_display='checkbox'; }                 $counter = 0;                 if(is_active_addons('monetization')){                      global $monetization;                     $total_price = $monetization->templ_total_price($taxonomy);                     $onclick = "onclick=displaychk();templ_all_categories($total_price);";                 }else{ $onclick = "onclick=displaychk()";}                 ?>

                 <input type="checkbox" name="selectall" id="selectall"  <?php echo $onclick; ?> /><?php _e('Select All',DOMAIN);?>
                 <?php                 foreach($catinfo as $catinfo_obj)                 {                     $counter++;                     $termid = $catinfo_obj->term_taxonomy_id;                     $term_tax_id = $catinfo_obj->term_id;                     $name = $catinfo_obj->name;                     $cp = trim($catinfo_obj->term_price);                     if(!isset($cp) || $cp==''){ $cp = 0; }                           $cat_term = explode(',',@$_REQUEST['category']);                     if(is_active_addons('monetization') && $cp !='0') { $dispay_price = " (".fetch_currency_with_position($cp).")"; }else{ $dispay_price = ''; } /* cat price works only with monetization */ ?>
                                                  <input type="checkbox" name="category[]" id="category_<?php echo $counter; ?>" value="<?php echo $term_tax_id.",".$cp ; ?>" class="checkbox" <?php if(isset($place_cat_arr) && in_array($term_tax_id,$place_cat_arr)){ echo 'checked=checked'; }?> onclick="fetch_packages('<?php echo $term_tax_id; ?>',this.form,'<?php echo $cp; ?>');"/> <?php echo $name.$dispay_price; ?>
                          <?php                      $child = templ_get_child_categories($taxonomy,$term_tax_id); /* $termid = parent id */                      $parent_id = $termid;                                 $i=1;                      $tmp_term_id=$term_tax_id;                      foreach($child as $term)                      {                                   if($term){                         $child_termid = $term->term_taxonomy_id;                         $term_tax_id = $term->term_id;                         $name = $term->name;                         $child_cp = $term->term_price;                          if(!$child_cp){ $child_cp =0; }                         if(is_active_addons('monetization') && $child_cp!='0') { $dispay_cprice = " (".fetch_currency_with_position($child_cp).")"; }else{ $dispay_cprice =''; } /* cat price works only with monetization */                         if($term->category_parent!=$parent_id)                         {   $i++;   $parent_id = $term->category_parent; }                           if($term->category_parent!=0):                     $p=$i*17;                                                            $pad = str_repeat(' -', $p);                                                    if($tmp_term_id==$term->category_parent)                             {                                 $i=1;                                 $p=$i*17;                                    $i++;                                 $pad = str_repeat(' -', $p);                                }                      ?>                         <div class="form_cat" style="margin-left:<?php echo $p; ?>px;">                             <input type="checkbox" name="category[]" id="category_<?php echo $counter; ?>" value="<?php if($child_cp != ""){ echo $term_tax_id.",".$child_cp; }else{ echo $term_tax_id.",".'0'; }?>" class="checkbox" <?php if(isset($place_cat_arr) && in_array($term_tax_id,$place_cat_arr)){echo 'checked="checked"'; }?>  onclick="fetch_packages('<?php echo $child_cp; ?>',this.form)"/> <?php if(@$child_cp != ""){ echo $name.$dispay_cprice; }else{ echo $name.$dispay_cprice; } ?>
                     <?php endif; }                     }                 }                 echo '
';// finish cf_checkbox div             }         }         /* End of checkbox */         /* Start of selectbox */         if($cat_display=='select' || $cat_display=='multiselectbox')         {              $args = array('hierarchical' => true ,'hide_empty' => 0, 'orderby' => 'term_group');             $terms = templ_get_parent_categories($taxonomy);                  if($terms) :                 if(is_active_addons('monetization')):                     if($cat_display=='select'):                         $fetch_pkg = "onchange=fetch_packages(this.value,this.form);"; /* FUNCTION FOR FETCH PACKAGES */                     else:                         $fetch_pkg = "onclick=fetch_packages(this.value,this.form);"; /* FUNCTION FOR FETCH PACKAGES */                     endif;                 else:                     $fetch_pkg = '';                 endif;                      if($cat_display == 'multiselectbox'){ $multiple =  "multiple=multiple"; }else{ $multiple=''; } /* multi select box */                 $output .= '<select name="category[]" id="select_category" '.$fetch_pkg.' '.$multiple.'>';                      $output .= '<option value="">'.__('Select Category',DOMAIN).'</option>';                 foreach($terms as $term){                        $term_id = $term->term_id;                     $scp = $term->term_price;                     if($scp == ""){                         $scp = 0 ;                     }                     /* price will display only when monetization is activated */                     if(is_active_addons('monetization') && $scp!='0') { $sdisplay_price = " (".fetch_currency_with_position($scp).")"; }else{ $sdisplay_price =''; }                     $term_name = $term->name;                     if(isset($place_cat_arr) && in_array($term_id,$place_cat_arr)){ $selected = 'selected=selected'; }else{ $selected='';} /* category must be selected when gobackand edit /Edit/Renew */                     $output .= '<option value='.$term_id.','.$scp.' '.$selected.'>'.$term_name.$sdisplay_price.'</option>';                          $child_terms = templ_get_child_categories($taxonomy,$term_id);      /* get child categories term_id = parent id*/                                        $i=1;                     $parent_id = $term_id;                     $tmp_term_id=$term_id;                     foreach($child_terms as $child_term){                          $child_term_id = $child_term->term_id;                         $child_cp = $child_term->term_price;                         if($child_term->category_parent!=$parent_id)                         {   $i++;   $parent_id=$child_term->category_parent; }                           if($child_term->category_parent!=0):                     $p=$i*2;                                                             $pad = str_repeat('-', $p);                              if($tmp_term_id==$child_term->category_parent)                             {                                 $i=1;                                 $p=$i*2;                                     $i++;                                 $pad = str_repeat('-', $p);                              }                             /* price will display only when monetization is activated */                             if(is_active_addons('monetization') && $child_cp!='0' ) { $cdisplay_price = " (".fetch_currency_with_position($child_cp).")"; }else{ $cdisplay_price =''; }                             $term_name = $child_term->name;                             if(isset($place_cat_arr) && in_array($child_term_id,$place_cat_arr)){ $cselected = 'selected=selected'; }else{ $cselected='';} /* category must be selected when gobackand edit /Edit/Renew */                             $pad = str_repeat('-', $p);                                   $output .= '<option value='.$child_term_id.','.$child_cp.' '.$cselected.'>'.$pad.$term_name.$cdisplay_price.'</option>';                                                                 endif;                     } //child category foreach loop                 }                 $output .= '</select>';             echo $output;             endif;         }         ?>


title: Different 'posts_per_page' setting for first, and rest of the paginated pages?

text: How do you set the `posts_per_page` query setting so that a different number of posts are displayed on the first of the paginated pages (of home, archive, search, etc.) and the rest of them? For example, say I'd like to display 10 posts on the first of the paginated pages of category archives, and 15 on the rest of them. How do I do it? This works:               function itsme_category_offset( $query ) {       if( $query->is_category() && $query->is_main_query() ) {              if( !$query->is_paged() ) {                $query->set( 'posts_per_page', 10 );              } else {                $query->set( 'offset', 10 );           $query->set( 'posts_per_page', 15 );              }       }     }     add_action( 'pre_get_posts', 'itsme_category_offset' );      **But...** According to the Codex entry for `WP_Query()` pagination parameters: > offset (int) - number of post to displace or pass over. **Warning: Setting > the offset parameter overrides/ignores the paged parameter and breaks > pagination** And according to the linked Codex entry for a workaround: > Specifying hard-coded offsets in queries can and will break pagination since > offset is used by WordPress internally to calculate and handle pagination. The indicated workaround uses a function that hooks into `found_posts` filter and establishes the offset. It supposes that I should do something like this:               function itsme_category_offset( $query ) {       if( $query->is_category() && $query->is_main_query() ) {         $paged = get_query_var( 'paged' );              if( 0 == $paged ) {                $query->set( 'posts_per_page', 10 );              } else {                $offset = 10 + ( ($paged - 2) * 15 );           $query->set( 'offset', $offset );           $query->set( 'posts_per_page', 15 );              }       }     }     add_action( 'pre_get_posts', 'itsme_category_offset' );          function itsme_adjust_category_offset_pagination( $found_posts, $query ) {       $paged = get_query_var( 'paged' );       if( $query->is_category() && $query->is_main_query() ) {         if( 0 == $paged ) {                $offset = 0;              } else {                $offset = 10 + ( ($paged - 2) * 15 );              }              return $found_posts - $offset;       }     }     add_filter( 'found_posts', 'itsme_adjust_category_offset_pagination' );      Since my simpler function works already, is the Codex warning still correct? (i.e. should I do it as shown in the second code block?) Was this offset/pagination issue fixed in a recent version of WordPress? And if so: how?


title: Some ways to debug code

text: I have a BuddyPress installation with many custom code. I had everything ready for production until I moved my database to shared hosting. The problem is that in strange ocasions, all the activities in `wp_bp_activity` gets deleted. I'm not saying that this problem ocured because I moved my database, but I cant reproduce this bug with my original installation (but had the same problem when I compied hosting database to new installation on my local machine) my details: 1) I don't beliave this `DELETE` is triggered with buddypress native code because everything staies as is in `wp_bp_activity_meta`. 2) I can't reproduce this bug and I can't understand when this happens. Also this does not happen often. maybe once or twice a day (or even once in two days). this is why it drives me crazy ) 3) The most interesting, it deletes EVERYTHING except "like". I'm using bp- like-unlike compontent. It deletes everything: avatar_change, comments, activity, my own components but not bp-like which is just a copy of original (liked). * * * UPDATE: As @S_HA_DUM suggested I turned `SQL` debbuging on and found (in 500mb data) this request (no error from php side) `DELETE FROM wp_bp_activity WHERE item_id = 0` the only thing I found that queries to `wp_bp_activitiy` is `delete` function (someone named it this simple :D) in buddypress plugin. but still can't find where this function is triggered I want some suggestions how to debug this error. Any help is welcomed


title: Show post if in category

text: I've searched a lot for options like has_category, in_category, get_the_category, but I couldn't make them work Here's my pastebin http://pastebin.com/Zi7auvtv I want this code to run only if the post belongs to the category "destaque" I didn't put my tries on the pastebin code to avoid being confusing Some of my tries:                   if (in_category('destaque')) {         echo 'The content';         }              OR              if (has_category('destaque')) {         echo 'The content';         }          But nothing work      And so on, tried a lot more complex too, but no luck Any ideas? Thanks!


title: Products not showing in category view

text: I have a website where various products are listed in categories. Initially all products were displayed correctly. Now two products out of five have stopped displaying for some reason. I have been through the settings and everything appears correct - the products are published, and I can see no difference between them and the products that do display. Does anybody have a sugggestion as to what would cause this behaviour? You can see one of the products concerned here: > http://whasup.ca/products-page/accessories/coil-leg-tether/ (Note the URL and 'accessories' category) The the corresponding Category page is here: > http://whasup.ca/products-page/accessories/


title: Having 2 subdomains work cohesively with the primary domain

text: I've never installed a WordPress multisite; I'm not even sure if that's what I need, but I am sure I could figure it out with no issues. My issue is that I'd like for a visitor to be able to log in or register from the root domain, example.com. I'd then like for that user to **not** have to "re-log in" when visiting a page on one of the subdomains, e.g. forums.example.com. All 3 domains (the root and the two subdomains) have separate WordPress installations, of course, A-records are all set up, and all are SSL'd. So **everything works**. I'd just like for one login to cover both subdomains (or all 3 sites) if possible. I'm using a premium front-end login and registration form (UserPro).   * Do I need to set up a multisite for the root + 2 subdomains? Any recommended options and guidance in helping me with this issue would be greatly appreciated! Thanks!


title: Disable wp-admin log on lightbox overlay

text: When you're logged into the WordPress admin, and your session times out, a lightbox overlay pops up requiring you to log back in. This is causing a problem for me. If we leave a tab open overnight, I'll wake up to thousands of page hits because of the lightbox refreshing wp-admin every few minutes to see if the status has changed. Question: Is there a way to disable the WordPress admin login lightbox?


title: Possible way to add Wordpress gallery caption

text: I am trying to add caption to Wordpress Gallery. I can only add caption to each images but, Is there a way to add caption to the gallery?


title: Highlighting Main Navigation Menu With Two or More Class Matches

text: I believe this doesn't happen very often. I am working on a project in which a child page can show up under several different parent pages. The page actually belongs to just one parent, but in the main navigation it needs to show up under two or more parents. Don't ask me why, people like to be redundant. I am using wp_nav_menu to create the main navigation. My structure is: Parent A \- child 1 \- child 2 Parent B \- child 1 \- child 2 \- child 3 (this child is the same as Parent A Child 2) Parent C \- child 1 \- child 2 (this child is the same as Parent A Child 2 and Parent B Child 3) \- child 3 I normally use the classes `current-menu-ancestor current-menu-parent` to highlight the navigation because they typically only show in one `<li>` , but because some children are listed several times under different parents, those classes are no longer unique to the page. So I ended up with two or more highlighted items. All other classes are also exactly the same in this case. There's not one unique class to select. Has anyone run into a similar issue? I can only fix this by using javascript, comparing ID and then unhighlighting the wrong ones. But I was wondering if there's a wordpress solution (filters) or a css solution.


title: Getting 404 after Update in Multisite

text: we have a multisite install width the following structure: http://domain.com/pages/myblog Where "pages" is blog 1. Other site in the network have domains like: http://anotherdomain.com/pages/blog All works fine. We can reach every site in the network and work on it. If we make an update, all sites point to the main site " _*_ ://domain.com/pages/" and not the domain which was set in the backend. This happens only after the upgrade. The htaccess, Domain Mapping or the sunrise.php are not being changed during the update. Deactivating all Plugins, also does not help. I did not make the install. Does anybody have an idea, what the issue could be? Many Thanks in avcance, Lars


title: post_content with line breaks

text: I want to be able to get post_content with line breaks. What is the best way to do it? I previously use the_content() which was working fine until I needed to install a plugin that adds share buttons on each post. Since then the output of my the_content includes texts from the share buttons. I tried to use post_contents which contains the correct content I need to output on my template file but the problem is the line breaks were stripped off. Is it possible to get post_content with line breaks preserved? Thanks


title: How to get menu strings, categories and tags into po file for translation

text: I'm prepping my theme for translation. I've added the following line to my functions.php, and added the text domain within my theme files.               <?php /*** LOAD THEME TEXTDOMAIN ***/     load_theme_textdomain( 'mytheme', get_template_directory() . '/languages' );          $locale = get_locale();     $locale_file = get_template_directory() . "/languages/$locale.php";          if ( is_readable( $locale_file ) ) {         require_once( $locale_file );     }          ?>      I've used poedit to generate my po files. It is finding some of the strings that are labeled with the text domain, but it's not finding my menu items, categories, or tags. Guessing I'm missing something? I did some digging and I couldn't find any answers. Ultimately this is for a front-end translation - wp admin will remain in english. BTW, the menu is based on wp-bootstrap-navwalker


title: create virtual subdomains for a bunch of urls on a site via .htaccess

text: I need to be able to create subdomains for a bunch of urls on a site,   from:   domain.ca/communities/city/nw/neighbourhood/ to:   neighbourhood.domain.ca      There are a couple of things that change in the structre of the urls that need to be taken into account for this to work. Notice that all the urls will have this in common domain.ca/communities/city/ and that the site is structure as follows: Arbour Lake being a "community" within the "NW" quadrant of my city "city" so the url will look like this so use this as an example: domain.ca/communities/city/nw/arbour_lake/   how do i use htaccess to make into this new subdomain neighbourhood.domain.ca      So the url will change depending on where that community is located it will be either NW, NE, SW, SE and Nearby for a couple of neighbouring communities to our cities. in which case it looks like this: domain.ca/communities/city/nearby/dewinton/ What kind of snippet can i paste into my htaccess file that will re-write ALL MY "community_pages" and use the name of the page as the root of the url followed by .domain.ca I forgo to mention that while these are "virtual urls with no/index.html file on that location" the folders do exist and follow the same tree structure. I am using wordpress and i tried SEO Redirection based on another thread on SO, but it would require for me to pu ch everything in manually. Thanks in advanced, any help would be greatly appreciated.


title: Weird characters behind every single link and images

text: My site http://ilovetaobao.my If you view page source, almost every single images and links have this in the end of the URL. **?84d5a9** For example like http://ilovetaobao.my/wp-content/uploads/2014/07/ilovetaobao- logo2.png?8aaf15 I've achieved 95/100 score in Google Page Insight, but today I check again it dropped to 59, and the culprit should be these links. My plugins: * Akismet  * Aqua Page Builder  * Contact form 7  * Contact form DB  * EWWW Image Optimizer  * Facebook Like Box  * Google Analytics for WordPress  * Hello Dolly  * Limit Login Attempts  * Remove query strings from static resources (Deactivated, but not solving the problem)  * TinyMCE Advanced  * W3 total Cache  * WordPress Importer  * WordPress SEO (by Yoast)  * WP-Optimize


title: Function to get content by ID

text: I'm trying to get text only content of posts by ID. I modified this function as follows, but at the moment it returns nothing. I cannot see what's wrong with it.               function get_the_excerpt_id($post_id) {         $find = get_posts($post_id);          $excerpt = $find->post_content;              $excerpt = strip_tags($excerpt);         $output = substr($excerpt, 0, 100);            return $output;     }      Any ideas what's missing? Marvellous


title: Migrating from WordPress.com to self-hosted site and autoforward visitors?

text: Having moved to my hosting my own WordPress blogsite I now need to ensure that readers find the new site rather than the old WordPress.com site. What is the best mechanism for doing this?


title: How to tell if $query_var isset?

text: I tired to use `isset($queryvar)` but that didnt work, so I implemented my own function `qv_isset`, but it runs into a problem when `$ch` is set to 0.               $cls = get_query_var('cls');     $ch = get_query_var('ch');          function qv_isset($var) {         if($var == '') { return false;          } else { return true; }     }          if(qv_isset($cls) && qv_isset($ch)) {         mcs_textbook_chapter($dialect, $cls, $ch);     } elseif(qv_isset($cls)) {                       mcs_textbook_chapter($dialect, $cls);     } else {         mcs_textbook($dialect);     }


title: How to use wp_list_pages on a grandparent page

text:
I am using wp_list_pages to show the page structure on a website. For instance, if I use this code, it will show me the complete child / grandparent heirarchy of the current page the user is on:               wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");      So this would generate something like this: (keep in mind, the user is on a page called About, which is the parent) ![enter image description here](http://i.stack.imgur.com/AXg2K.png) This works great, but if you were to click on any grandparent page (Like Partners), the `wp_list_pages` code does not work. I have implemented a conditional statement which will use different code on a child page then the grandparent page. So that said, I have the child pages working great. I just need to figure out how to display this same exact menu on the grandparent pages. Any idea? Here is how the conditional work:               <?php if( count(get_post_ancestors($post->ID)) == 2 && $post->post_parent){ ?>          I need new code here          <?php } elseif(count(get_post_ancestors($post->ID)) == 1 && $post->post_parent){             $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");             echo $children;     }     else { ?>
Parent Page
     <?php } ?>


title: Cannot save Post

text: I recently upgraded to 3.9.1 and cannot Save a draft, nor publish. I have the draft written, click Save Draft and nothing happens other than the spinning icon next to the button. I have disabled all plugins with no difference. I have re-installed 3.9.1 to no avail. If I pull up Chrome Developer tools I see the request go out, but it just stays in a 'pending' state with no return at all from the server. Has anyone seen this behavior, if so how do I remediatie it?


title: send users logging in from wp-login.php directly to home page of site, rather than dashboard

text: I am currently using a plugin called Sidebar Login which allows users to bypass the dashboard and go directly to the site. However, when users login via `/wp-login.php` (e.g. when they click on their verification links in their emails), they are once again sent to the dashboard. I would like for users to be able to click on their verification links and have them directed to the home page of the website where they can sign in through the sidebar login I have set up. Is this possible?


title: Override theme style with other CSS on a specific page

text: The wordpress theme I bought has some jQuery UI styling included in its default CSS file. The problem is I have a plugin that uses jQuery UI and the theme's default CSS makes the plugin corrupted. I want the default jquery UI CSS file to override UI styling contained in my theme's CSS file.   I see some people mentioned using Enqueue to make the jQuery CSS load in the bottom of the page, but I don't know how to do this. Thanks.


title: From what hook on is it possible to conditionally add actions?

text: I tried to have a siderbar registered at the "init" hook based on a variable from the theme options array indicating whether the sidebar should be used in the design. Now it appears that that the condition works fine (tested with some other code) but if I use `add_action( 'init', 'register_sidebar_x' );` or `add_action( 'wp_loaded', 'register_sidebar_x' );` based on the condition being true, nothing happens, and the sidebar won't be registered, while it will be registered just using the code outside of the control structure using either hook. So it appears that the init function is executed before the functions.php has access to the theme options array (which is included). The control structure works with "wp_head", for example. So my question is - from what hook on is it possible to use conditionals and is there one that can be used to register sidebars after that point? **UPDATE:** OK, here's the current code trying to incorporate some suggestions from below... The sidebar is registered just fine if I'm not testing for the condition, but the condition clearly is 'yes'. Is there any way to conditionally register sidebars?               add_action( 'after_setup_theme', 'aad_theme_setup' );          function aad_theme_setup() {              if ( function_exists( 'get_option_tree') ) {             $theme_options = get_option('option_tree');         }              if ($theme_options['aad_sliding_sidebar']=='yes') {             add_action( 'widgets-init', 'aad_register_sidebar_function' );           }     }      So it still doesn't work... thanks for any additional suggestions!


title: Customize how a Wordpress theme looks like in the Theme Selector

text: How do I customize how my theme shows up in the list of available themes in the Admin console, under the "Appearance" -> "Themes" section. I need to change stuff like the theme name, author, and description.


title: Custom Metabox additional item

text:
I have a custom metabox that have 2 options: URL and a text box called "testimonial". The URL box is working great(when i put some text in this field on admin, the text appears on site), but the testimonial box(same proposal) dont works. What is wrong or what is missing?               <?php          add_action('admin_init', 'portfolio_meta_init');          function portfolio_meta_init() {         // add a meta box for WordPress 'project' type         add_meta_box('portfolio_meta', 'Project Infos', 'portfolio_meta_setup', 'project', 'side', 'low');              // add a callback function to save any data a user enters in         add_action('save_post', 'portfolio_meta_save');     }          function portfolio_meta_setup() {         global $post;         ?>
             URL
                 <input type="text" name="_url" value="<?php echo get_post_meta($post->ID, '_url', TRUE); ?>" style="width: 100%;" />
                  Testimonial
                 <input type="text" name="_testimonial" value="<?php echo get_post_meta($post->ID, '_testimonial', TRUE); ?>" style="width: 100%;" />

         <?php         // create for validation         echo '<input type="hidden" name="meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />';     }          function portfolio_meta_save($post_id) {         // check nonce         if (!isset($_POST['meta_noncename']) || !wp_verify_nonce($_POST['meta_noncename'], __FILE__)) {             return $post_id;         }              // check capabilities         if ('post' == $_POST['post_type']) {             if (!current_user_can('edit_post', $post_id)) {                 return $post_id;             }         } elseif (!current_user_can('edit_page', $post_id)) {             return $post_id;         }              // exit on autosave         if (defined('DOING_AUTOSAVE') == DOING_AUTOSAVE) {             return $post_id;         }              if (isset($_POST['_url'])) {             update_post_meta($post_id, '_url', $_POST['_url']);             update_post_meta($post_id, '_testimonial', $_POST['_testimonial']);         } else {             delete_post_meta($post_id, '_url');             delete_post_meta($post_id, '_testimonial');         }     }          /* --- #end  Demo URL meta box --- */ ?>      The outputs:               <?php echo get_post_meta($post->ID, '_testimonial', TRUE); ?>     <?php echo get_post_meta($post->ID, '_url', TRUE); ?>


title: Image width issue in IE

text: For some reason images are being displayed as a thin line in IE 8 and earlier and i cannot work out why this could be. I'm using CSS to re-size the images for the homepage, the reason for me using CSS to re-size the images is because the thumbnails are being generated by Wordpress. This is what it looks like in IE... ![IE8 and below - thin images](http://i.stack.imgur.com/KlXch.png) How it looks in Firefox and all other browsers... ![Firefox and other major browsers](http://i.stack.imgur.com/cgXfO.png) The CSS i'm using to size the images...               .home .attachment-home-post-thumbnail {         box-shadow: none;         height: 125px;         margin-right: 8px;         margin-top: 8px;         width: 140px;     }      Any ideas?


title: How can i display movies in profile page, added by an user?

text:
How can i display movies added by an editor in profile page, i mention that the user (editors) have capabilities to add movies. I shoud use a querry? with args? I mention that the post_type is "post" - for movies ////// "trailers" - for trailers I want to get movies and trailers on the profile user page. How can i do that?               ----------------------------------- UPDATED -------------------         <?php         global          $current_user;          $current_user = wp_get_current_user();         $recentPosts = new WP_Query();         $recentPosts->query(array(             'author' => $current_user->ID,             'post_type' => 'post'));         ?>         <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
         <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Film %s'), the_title_attribute('echo=0')); ?>">         <img src="/scripts/timthumb.php?src=<?php the_field('img'); ?>&h=120&w=90&zc=1" alt="" title="<?php the_title(); ?>" />
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">         <?php the_title(); ?>

         <?php endwhile; ?>
     ----------------------------------- UPDATED -------------------      Here is an image how it look's http://s12.postimg.org/ssacplu3x/filme.jpg Thanks.


title: Why does get_transient() always return string even if integer set?

text: I've been trying to bug fix the following method for hours now, and don't have an idea why it always returns a string, instead of an integer. The idea is to return a class property, if exists, or a transient value, if the class property doesn't exist (and setting the class property for the next access).               public static function get_number( $post_id = null ) {         // Check if class property already exists         if ( empty( self::$number ) ) {                  // THIS IS ALWAYS STRING - WHY?             $number = get_transient( 'my_number' );                  if ( false === $number && $post_id ) {                 $number = get_post_meta( $post_id, 'my_number', true );                      if ( '' !== $number ) {                     $number = intval( $number );                     // THERE GOES THE INTEGER                     set_transient('my_number', $number, 20 );                 }             }                  self::$number = $number;             // Should still be an integer since we've never set any strings to transient         }              return self::$number;     }      Weird thing is when I call it with a valid `post_id`, I'll get an integer but when calling without, I'll get a string. So...   `gettype( get_number( 123 ) ) === 'integer'`   `gettype( get_number() ) === 'string'` **Working Code (based on Otto's answer)**               public static function get_number( $post_id = null ) {         // Check if class property already exists         if ( empty( self::$number ) ) {                  // THIS IS ALWAYS STRING - WHY?             $number = get_transient( 'my_number' );                  if ( false === $number && $post_id ) {                 $number = get_post_meta( $post_id, 'my_number', true );                      if ( '' !== $number ) {                     // THERE GOES AN ARRAY OF THE INTEGER                     set_transient('my_number', array( intval( $number ) ), 20 );                     self::$number = intval( $number );                     return intval( $number );                 }             }                  self::$number = isset( $number[ 0 ] ) ? $number[ 0 ] : '';         }              return self::$number;     }


title: display specific custom fields

text:
I have few custom field assigned for each post, like: "Club" with value "club1" "Date" with value "date1" and so on... Now, I want to display from all the custom fields just those 2 " club" and "date". This is my markup :
<?php the_meta(); ?>
      The problem with this, is that is retrieving all the custom fields and I don't want this. I was thinking to add css psedoselector like nth:child(n) but I'm sure that I can do this with this function. Thank you!


title: Interesting Custom Post Type Slug with Taxonomy and Custom Field

text: I have created a custom post type called "events" and have also created a custom taxonomy which only shows up on this specific post type through which the admin must select an "event category" (terms). Currently on the public site when the event detail page is requested it looks like this: http://www.domain-name.com/events/title-of-the-event Additionally, on the public side a web browser can access just a specific event category to view all associating events where the url looks like this: http://www.domain-name.com/events/event-category Both of the above situations currently works fine. The problem I am having is that I would like to customize the URL slug for the event details page as follows: Instead of having the event detail page slug being built from the entered title I would like for it to include the taxonomy term and a specific custom field. In end effect I would like for it to look like this:               http://www.domain-name.com/events/<taxonomy-term>-event-title-<custom-field>/        * `<taxonomy-term>` is the event category (the way I programed the metabox the admin is only able to select a single term).   * `<custom-field>` is a specific custom field the user is required to enter before the event post can be saved. Does anyone know how I might go about doing this correctly? All my experiments have led nowhere.


title: How to re-Import the WordPress XML file after editing?

text: I have exported all my content to WordPress XML file via WordPress>Tools>Export as I needed to edit 300 posts at a time. Now, my concern is how to re import the file to override the default one? By re- importing the file via WordPress Tools it does only import new posts, so it's not adapted to that particular case without breaking my site/database. I need to find a way to re import the file. Any suggestion is appreciated.


title: How to change the admin menu "Pages" to something else

text: When one creates a custom post type you have the ability to define various elements related to that post type which essentially allow you to define things such as the menu title, "add new post" text and stuff like that. What I am trying to figure out is what code I need to add to my functions.php file so I can set these things for an existing "default" post type which wordpress adds. So, for example lets say I want to change the "Pages" post type to "Main Sections". Currently what I have done is used the following code:               add_filter( 'gettext', 'change_admin_menu_pages' );     add_filter( 'ngettext', 'change_admin_menu_pages' );     function change_admin_menu_pages( $translated ) {         $translated = str_replace( 'Page', 'Core Page', $translated );         $translated = str_replace( 'page', 'core page', $translated );         return $translated;     }      Although this works and just replaces every instance of "pages" with "main sections", what I have noticed is that it also effects other areas of the site such as plugins which use "pages=" within their url. As such... is there a simple way to define post type settings for default wordpress post types like "pages" and "posts"? If so, could someone please quickly illustrate how that might work? On a different note... I feel that using the filter   * add_filter( 'ngettext',...) is actually very useful but what I don't understand is how to restrict the area where its allowed to filter things. An answer to both or either question would be greatly appreciated Thanks in advance!


title: Custom Post Types - Titles as Taxonomies

text: I am developing a church media center using custom post types. I have a custom post type called 'Series' and a custom post type called 'Sermons'. Each Series must have an Title, Image, and Description. Naturally, each Series will be a collection of Sermons (Which will have Audio, Video, and other metadata). I need to create a Parent/Child relationship with the Series and Sermons. Ideally, when creating a New Sermon entry, I'd like a dropdown list whose options are populated by any available Titles in the post type "Series". Any suggestions in how to accomplish this?


title: How to Override default update_count_callback for category

text: Is it possible to override default `update_count_callback` for category? The default function counts published posts while I want to count private posts. I do not want to register a new taxonomy.


title: Keep formatting for tables copied from MS Word?

text: I've found that copying and pasting tables from MS Word was closest to easiest when it comes to making tables; rather than formatting a table from scratch in a WYSIWYG editor. The one shortfall I've found is that the "center" formatting does not copy over. It LOOKS like it does but the formatting is not actually applied. you have to go through each cell and center it. Just wondering if anyone has a clue on how the WP editor handles MS Word and maybe if there's a fix?


title: Add Google Map By Address

text: Is there a plugin that allowed me to add google map embed code by only supplying address?


title: Removing the "Popular Terms" area from the Taxonomy Edit Screen in the Admin Area

text: Personally I really dislike how wordpress shows all the "popular terms" in different sizes on the taxonomy add/edit screen in the admin area. Does anyone know of a way to either remove this entire area completely by adding code to your functions.php file and/or how to just change this specific area so that none of the popular terms show up with different font sizes/styles? Thank you


title: Wordpress Page Hierarchy

text: I have the following page on a site in development: http://telamon.com.s137737.gridserver.com/media/press/ I want to do some stuff outside the loop, so I created page-press.php based on my understanding of the WP page hierarchy (http://codex.wordpress.org/Template_Hierarchy). It isn't working. I've reset permalinks as well. This isn't the first time I've had problems here and I just ended up creating a template, but this should work shouldn't it? Thanks Brett


title: Show children of top level category only

text: Imagine i have a URL structure like this: www.domain.com/category/subcategory/ This is my code:               <?php     $args=array(         'child_of' => $cat-id,         'hide_empty' => 0,         'orderby' => 'name',         'order' => 'ASC'     );     $categories=get_categories($args);     foreach($categories as $category) {          echo 'term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'';  }      ?>      When I'm on "www.domain.com/category/" the code correctly displays all children of the category, but when on "www.domain.com/category/subcategory/" the code doesn't display any results because the subcategory doesnt have any children. I need the code to only display the children of the top-level category even when on it's child pages. How do i accomplish this? TIA.


title: wp_redirect not working on admin menu page

text: Im trying to create a admin menu link on the backend dashboard, that will take users to the front end of their site. Im trying to use this code, but for some reason the redirect is not working.               // Custom Menus     add_action('admin_menu', 'register_web_menu_page');     function register_web_menu_page() {         add_menu_page('View My Website', 'View My Website', 'add_users', 'web_menu_page', 'web_menu_page', '', null, 9);      }          function web_menu_page(){        wp_redirect( home_url() );      exit;     }      The user clicks the menu link and are take to the web_menu_page and are not being redirected to the home url. Im not sure why it isnt redirecting, any help?


title: Bulk edit of EXIF data for jpeg images uploaded in the media library?

text: Although there's a number of plugins that display EXIF data in your posts or remove EXIF data altogether to save space, I couldn't find a solution to manually edit EXIF data for whole bunches of images (eg. remove some data, replace other, selectively edit some EXIF fields, etc.). Is there any plugin to do this within the WP dashboard? Otherwise can you recommend any external non-WordPress tool that can log into (S)FTP fetch my files in upoads and can do the same task? The thing is it should work also for scaled media (thumbnails), each image could have more than one size - edits should apply for any of these while editing a single image.


title: How to query for posts without a post_format

text: I have looked in the WP codex for an example which shows how to use a taxonomy query to retrieve a set of posts that have no post_format. IOW: 'All posts where an aside or quote or link...etc... post_format has not been assigned; eg. a 'standard' post_format.' But I can't seem to figure out how to query for posts that have -no- post_format. IOW: it seems as though if the post has no post_format (eg. 'aside' or 'quote') it returns an empty result in get_post_format()               $args = array(       'post_type' => 'post',       'tax_query' => array(         array(           'taxonomy' => 'post_format',           'field' => 'slug',           'terms' => array(?????)          )        )     );     $query = new WP_Query( $args );      How does one set up this kind of query?


title: Can slugs from posts and custom post types conflict?

text: I have a system built on WordPress where we're using several custom post types, and I'm seeing some weird behaviour. For instance, I have a CPT called "Flyers", and I also have a CPT called "Templates". The Templates CPT has a post called "Flyers". In Flyers CPT I have a post called "Flyer 01". Now when I try to $_POST to the Flyer 01 permalink (/flyers/flyer-01/) it looks like WordPress is redirecting my request to Templates post called Flyers (/templates/flyers/). Does anyone have any good ideas on what's going on here? And how do I get it to stop doing that redirect?


title: How can I get thumbnail image for product from WooCommerce Database?

text:
I have created a search box for finding product. Here all things are working fine except the product image. This is the code that I created:               <?php      $a=0;     $b=0;     $value=$_GET['se'];     //$re2=mysql_query("SELECT *from wp_posts WHERE post_type='product' and post_title LIKE '%$value' ");     $re2=mysql_query("     SELECT DISTINCT wp_posts.ID,wp_posts.post_title,wp_posts.post_content,wp_terms.name from wp_posts     INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id     INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id     INNER JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id     INNER JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id     WHERE wp_posts.post_type='product' and (wp_terms.name LIKE  '%$value' or wp_posts.post_title LIKE  '%$value' or wp_posts.post_content LIKE '%$value')");          while($row2=mysql_fetch_assoc($re2)){         $id2=$row2['ID'];         $ids=$row2['ID']+1;         echo $row2['post_title']."
";         echo "Product category : ";              $re=mysql_query("         SELECT DISTINCT wp_terms.name from wp_posts         INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id         INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id         INNER JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id         INNER JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id         WHERE  wp_term_taxonomy.taxonomy='product_cat' and  wp_term_relationships.object_id='$id2'");         while($row=mysql_fetch_assoc($re)){             echo $row['name']." , ";         }         echo '
         Product tage name : ';         $re3=mysql_query("         SELECT DISTINCT wp_terms.name from wp_posts         INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id         INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id         INNER JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id         INNER JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id         WHERE  wp_term_taxonomy.taxonomy='product_tag' and  wp_term_relationships.object_id='$id2'");         while($row3=mysql_fetch_assoc($re3)){             echo $row3['name']." , ";             $b++;         }         if($b==0){echo 'no tage';}         echo '
';             $re1=mysql_query("SELECT * FROM  wp_postmeta where post_id='".$ids."' and meta_key ='_wp_attached_file' ");             while($row1=mysql_fetch_assoc($re1)){             $img=$row1['meta_value'];                }                  //echo $row['post_content']."
";                  echo ''."
";             echo "

";             $a++;          }     if($a==0){echo "Sorry there is no such products in this list";}          ?>


title: How to highlight search terms without plugin

text: How can I get the search terms highlighted without plugin?


title: Displaying multiple post types on home page

text:
I've read several examples of how to do this but I still can't get it to work - each time I use get_posts() it seems to only keep and display the first set of results. loop.php               function home_index() {          global $post;          echo '
';          $args = array(         'numberposts'     => 3,         'offset'          => 0,         'orderby'         => 'post_date',         'order'           => 'DESC',         'post_type'       => 'gp_news',         'post_status'     => 'publish',         'meta_key'        => '_thumbnail_id',         'meta_value'      => 1,         'meta_compare'    => '>='     );          $myposts = get_posts( $args );          foreach( $myposts as $post ) {         setup_postdata($post);         echo '
';              if ( has_post_thumbnail() ) {             the_post_thumbnail( 'homepage-thumbnail' );         }         ?>
news <a href="<?php the_permalink(); ?>" title="Permalink to <?php esc_attr(the_title()); ?>" rel="bookmark"><?php the_title(); ?>
         <?php the_excerpt(); ?>         <a href="<?php the_permalink(); ?>">Continue...         <?php         echo '
';     }          $args = array(         'numberposts'     => 1,         'offset'          => 0,         'orderby'         => 'post_date',         'order'           => 'DESC',         'post_type'       => 'gp_competitions',         'post_status'     => 'publish',         'meta_key'        => '_thumbnail_id',         'meta_value'      => 1,         'meta_compare'    => '>='     );          $myposts = get_posts( $args );          foreach( $myposts as $post ) {         setup_postdata($post);         echo '
';              if ( has_post_thumbnail() ) {             the_post_thumbnail( 'homepage-thumbnail' );         }         ?>
competition <a href="<?php the_permalink(); ?>" title="Permalink to <?php esc_attr(the_title()); ?>" rel="bookmark"><?php the_title(); ?>
         <?php the_excerpt(); ?>         <a href="<?php the_permalink(); ?>">Continue...         <?php         echo '
';     }          echo '
';             }


title: Free starter theme to make mobile websites?

text: Is there any free starter theme to make mobile websites using WordPress?


title: Permalink with sub-sub-category and post name

text: Working on a new theme project and I created a custom post type called products with its own custom taxonomy. I want the URL structure to be: > > > http://example.com/products/main_category/subcategory1/subcategory2/postname/ >   I found this solution here:               function filter_post_type_link($link, $post)         {             if ($post->post_type == 'products')                 return $link;                  if ($cats = get_the_terms($post->ID, 'product_categories'))                 $link = str_replace('%product_categories%', array_pop($cats)->slug, $link);             return $link;         }         add_filter('post_type_link', 'filter_post_type_link', 10, 2);      With this solution I was able to create this structure: > >     http://example.com/products/category/postname/ >   So subcategories still won't show in the URL... The other problem is that when I set the taxonomy `hierarchical => true` the url looks like this when I browse the product categories: > > > http://example.com/products/category1/subcategory1-category1/subcategory2-subcategory1-category1/ >   and also when `hierarchical => true` is present the code I mentioned above stops working. So what I want to achieve with product urls basically is this: If product belongs to the main category: > >      http://example.com/products/main_category/postname/ >   If product belongs to subcategory1: > >      http://example.com/products/main_category/subcategory1/postname/ >   If product belongs to subcategory2: > > > http://example.com/products/main_category/subcategory1/subcategory2/postname/ >   Of course if I delete post name from the above urls wp should show the appropriate category. This would be a nice hierarchical structure. Do You know any solutions to make this happen? Best Wishes, Matt


title: Why the form's get method redirects to edit.php in wordpress admin?

text: I have a form in wordpress plugin and i am trying to submit it using the get method. The problem is that, the form redirects to edit.php page instead my custom post type page, which is `post_type=tender&page=my-tenders.`               <form name= "name" action="" method="get" >     <input type="text" id="search_input" name="search_input"/>         <input type="submit" id="search_button"  value="<?php  _e( 'Search', 'woo-tender') ?>"/>     </form>      Here is where it redirects to after submitting the form               localhost/wp/wp-admin/edit.php?search_input=product_name      Instead of:               localhost/wp/wp-admin/edit.php?post_type=tender&page=my-tenderssearch_input=product_name


title: Is There A Way To Add Another Field To Custom Post Type (Not Custom Field/Meta)?

text: Maybe I'm not getting the whole concept, but is there a way to modify a Custom Post Type so that it includes other 'fields' like a 'real' db table. I don't mean a Custom Field (get_meta)... I mean inside the table that can be manipulated with rules. I want to make a post type with several -mandatory- fields. eg.               Song Record:      <Title      <Lyrics      <Date      <Length      <MP3      :end      Yeah, I can do that with a bunch of custom fields, but I was wondering/hoping if this structure could all be laid out with Register_Post_Type so it could be manipulated as a single 'object'... as one can do in Drupal. Or have I got this all wrong? \---JC


title: Creating two loops. First for latest post or latest sticky, second for all other posts

text:
I'm new to Wordpress and PHP and I've been battling with this for a while now. What I have for the moment is 2 loops. I want to first loop to only ever show 1 post: either a sticky post, or the latest post if there are no sticky posts. The second loop should show all other recent posts, like a basic blog, except any posts which are stickied or the recent post which appears in the first loop. What I have: My code shows the latest post in the first loop and other posts in the second loop. The problem: When I make a sticky post, it appears in the first loop along with the latest post (I only want the sticky post to appear here in this situation and not both), and it also appears at the top of the second loop. Here it is in action: http://bit.ly/1qS0MMC I've managed to get this far but I can't seem to finish it.

                    <?php $args = array(                       'posts_per_page' => 1,                          );                        $my_query = new WP_Query( $args );                        while ( $my_query->have_posts() ) : $my_query->the_post();                    $do_not_duplicate = $post->ID; ?>                  <div id="post-<?php the_ID(); ?>" <?php post_class( '' ); ?> >
                     <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('home-thumbnail'); ?>

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

       <?php endwhile; ?>

     <?php         $counter = 1; //start counter         $grids = 2; //Grids per row         global $query_string; //Need this to make pagination work          if ( have_posts() ) : while ( have_posts() ) : the_post();     if ( $post->ID == $do_not_duplicate ) continue; ?>          <?php     //Show the left hand side column         if($counter == 1) :     ?>             <div id="post-<?php the_ID(); ?>" <?php post_class( 'griditemleft' ); ?> >
                     <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('home-thumbnail'); ?>

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

     <?php     //Show the right hand side column     elseif($counter == $grids) :     ?>     <div id="post-<?php the_ID(); ?>" <?php post_class( 'griditemright' ); ?>>
                     <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('home-thumbnail'); ?>

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

     <?php     $counter = 0;     endif;     ?>     <?php     $counter++;     endwhile;     //Pagination can go here if you want it.     endif;     ?>     <?php     untitled_content_nav( 'nav-below' );     ?>


title: Save image url in custom field wp user frontend

text: i have problem to save image url from the frontend. I use wp user frontend to save the image. The plugin save the image uploaded in custom field as attachment ID not url. I need the url saved in database. Can someone help me what code need to replaced or changed in plugin core to make the image url saved in custom field. Thank you.


title: Media not uploaded in buddypress activity wordpress running on google app engine

text: I have deployed wordpress in google app engine. I enabled plugin named buddypress. Everything works fine but uploading media not worked at all. I am not able to upload avatar too. Please help me. Thanks to all.


title: How to specify multiple search columns for wp list table search

text: I have working search for a created `wp_list_table`. But i like to know how I can search in more than one column. My current my working search setup in a Visitor class               //search something     $searchcol= array(         'visitorCompany',         'visitorName',         'visitorEmail'         );       $search = !empty($_REQUEST["s"]) ?  mysql_real_escape_string($_REQUEST["s"]) : '';     //$search = preg_replace( "^$\**(.*)\**$?#", "*$1*", $_REQUEST["s"] );     if(!empty($_REQUEST["s"])) {$query .= ' WHERE '.$searchcol[1].' LIKE "%'.$search.'%"';}      here I just searching in the `visitorName` column, but i like to use the `$searchcol` to search in. A foreach loop               foreach( $searchcol as $col) {         if(!empty($_REQUEST["s"])) {$query .= ' WHERE '.$col.' LIKE "%'.$search.'%"';}     }      didn't work


title: How to create an overview of posts with the same tag?

text: At the bottom of each post, I want to display posts that have the same tag. Based on numerous examples of function doing something similar, I created the function below. I call it from with in the loop from the custom post php that I created. It's called succesfully, but I don't get the list of titles that I expect to get. How do I solve this?               function show_related(){              $posttags = get_the_tags();         if ($posttags) {             $ids = array();             $relatedpostids = array();             foreach ($posttags as $tag){                 $id =  $tag -> term_id ;                 $ids[] = $id;             }             foreach ($ids as $id){                  $args = array(                     'tag_id' => $id,                 );                 $posts_array = get_posts( $args );                 foreach( $posts_array as $post ) {                     echo the_title();                 }             }              }     }


title: Loop and add Specific Categories and Products Images

text:
Thanks to Rafael Marques I have a list of Products and Categories organized based on different created categories. I also have 5 different Custom Page Templates. Now I would like to display the products images (Only Images, because this is just an image gallery) in each of the pages. The Page temlate looks like:               <?php      /**     Template Name: Gallery Art     */     ?>     <?php  get_header();?>

     <?php get_footer(); ?>      Can you please let me know how I can do this based on Categories? For Example let say I have a Page called Art and powered based on Art_Page template.Now how I can add all images(products) to only this template which categorized under artCat? Thanks


title: Custom Fields help

text:
After read a lot in a lot of sites, finally I was able to do something similar what I was trying (read a lot because I don't know code at all), is the follow: I want to use a background image for my custom fields. I did this in `single.php`:

                  <?php $firstCF = get_post_meta($post->ID, 'firstCF', true);     if ($dorigen) { ?>                  My text: <?php echo $firstCF; ?>

       <?php }      else { ?>
<?php } ?>
                  <?php $secondCF = get_post_meta($post->ID, 'secondCF', true);     if ($dorigen) { ?>                  Other Text: <?php echo $secondCF; ?>

       <?php }      else { ?>
<?php } ?>
`          CSS:      .post-meta {         text-shadow: 0 1px 0 #252525;         color: #f2f6d7;         padding-top: 22px;         padding-left: 190px;         float: left;         height: 150px;         width: 600px;         background-image: url(../images/fondo-campos-personalizados.gif);         background-repeat: no-repeat;        }      The problem is that will not use always `firstCF` and/or `secondCF` in all my post and the background image always is there. Another Q: I use `h3`, but when I see source in browser I can't find `</h3>`, but the size and characteristics of the text are really those of my css `h3`. I don't know if Google and others, will understand that they are really `h3`. Is there a way to do something like this?


title: Using wp_list_table how to trigger update function "inline"?

text: Ok, i have used wp_list_table to read data from a custom db table and i like to be able to update the database table by clicking the correspondig cell. Defaults are 0 and when clicked the value is set to 1. so by clicking the cell updateVisitor() will be triggered "inline" my function which i isn't part of the Visitors extend WP_list_table class               function updateVisitor($id){         global $wpdb;         $query = $wpdb->prepare( "UPDATE tbl_visitor SET visitorPayed =BINARY(visitorPayed=1) WHERE visitorID = %d", intval($id) );         $result = $wpdb->query( $query );     }


title: Most commented last 24h, week, month, year and all time - posts_where

text: I've removed my old post here, as the posts_where method is outdated. Thanks to kaiser, this is now how easy it is to list most commented posts within a certain time span:               <?php     $popular = new WP_Query( array(         'post_type'             => array( 'post' ),         'showposts'             => 6,         'cat'                   => 'MyCategory',         'ignore_sticky_posts'   => true,         'orderby'               => 'comment_count',         'order'                 => 'dsc',         'date_query' => array(             array(                 'after' => '1 week ago',             ),         ),     ) );     ?>     <?php while ( $popular->have_posts() ): $popular->the_post(); ?>         <?php the_title(); ?>     <?php endwhile; ?>      Note: this sorts by most commented **articles posted within X date** , not checking all articles and then looking for most amount of comments within that time span among all articles. No idea how to do the second one, or how heavy it would be.


title: How many Wordpress SQL Queries per page?

text: I am on a shared hosting which has a limitation at MySQL queries per hour. My shows unable to connect to database because of this. Can anyone tell me how many queries are per page on a wordpress site with default theme instaled on? PS: I haven't any plugin installed.


title: wp_nav_menu changed to wp_page_menu

text: I've styled my navigation menu with the classes of wp_nav_menu .menu_item , .sub_menu etc.When i added a new page suddenly the whole menu was ruined the classes where changed to .page_item, .children the ul was wrapped with a div container.I checked the code and the function wwas wp_nav_menu...What should I do to get the old menu style? ## Edit               wp_nav_menu( array(          'theme_location' => 'main_menu',          'container' => '',          'menu_class' => 'menu'       ) );


title: In a page I need to display posts "standard" and post "videos" with post formats

text: I have created a filter to display "standard" posts in a page by selecting category and it works well but it deletes "video" posts. I need to create another filter to display the "video" posts from the category which is displayed, this filter isn't correct but i don't know how to do it... Filter to show "standard" posts :               add_filter('posts_where','website_inter_posts_where',10,2);     function website_inter_posts_where($where,$query) {       global $wpdb;       $new_where = " ({$wpdb->posts}.ID NOT IN (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_format_video_embed' AND LENGTH(meta_value) > 0 ))";       if (empty($where))         $where = $new_where;       else         $where = "{$where} AND {$new_where}";       return $where;     }      How to do this?


title: Show a Category X's custom post type on Category X archive page?

text: I created a custom post type "landing_page" to hold content I want to display on the top of category archive pages. So for each category, I have one landing_page entry tagged with that category. What do I have to add to the category archive.php template to get it to show that category's (or custom taxonomy term's) landing_page content?               query_posts(         array( 'posts_per_page' => 1,         'post_type' => landing_page,         'category' => [[???]] ));               while (have_posts()) : the_post();         the_content();     endwhile;     ?>


title: How to deal with different jQuery versions?

text: For example   If you have a plugin on a site that uses jQuery 1.5.x and want to create a new plugin by implementing a script which uses an older version of jQuery, for example 1.3.x or 1.4.x. I know it probably depends on jQuery functions that are called, but if you really had to use both 1.5 and some older version of jQuery.. how would you deal with this kind of situation? Is it even possible to use 2 different versions of jQuery at the same time without drawbacks? Thanks.


title: What is wrong with this code?

text: function themeperauthor_need_switch() {         global $post;       if ( $get_post_type == 'weblogs' )  {         return get_the_author_meta('themeperauthor', $user->ID);       }       return "";     }      It doesn't return anything


title: WordPress Htaccess Redirect Loop

text: I have a site with a wordpress blog in a sub-folder named blog. I added an .htaccess file to the main folder, with just the following lines:               Options +FollowSymlinks     RewriteEngine on     Rewritecond %{http_host} ^mysite.com [nc]     Rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]      This is standard: the purpose is for each page to have the "www". I've used it for many sites and it works fine for the non-wordpress pages of the site. Problem is that now when I visit my blog, instead of getting the page, I get "This webpage has a redirect loop". I imagine the cause is the .htaccess of the main folder and the .htaccess of the blog folder. Any idea what I need to do?


title: Updating options into the wp database performance

text: I have a question about the performance of my plugin. On the settings page of my plugin I have about 20 options the user can change (checkboxes, dropdown and normal text inputs). Currently I just update all options on submitting the form. Is it better for performance to first check if an option is updated before I really update the option? So that it doesn't write to the database if the option isn't changed?


title: Can't use orderby in WP_Query

text: I can't get my posts to order by the date, descading. I've got the following code:               $jobs = new WP_Query(array(         'posts_per_page' => 50,         'post_type' => 'job',         'post_status' => 'publish',         'orderby' => 'post_date',         'order' => 'DESC',         'cache_results' => false     ));      And this is the output of `$jobs->request`:               SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'job' AND ((wp_posts.post_status = 'publish')) AND post_date >= "2014-09-10"   LIMIT 0, 50      Somehow the whole ordering section is missing, and there's 3 spaces instead. What happened?


title: Calculate future date

text: I want to calculate a future date based on the date the post is published and use it in the content of a post. I can echo the post publication date using:               echo the_date('Y-m-d');      How can I calculate the future date?