[wp-trac] Re: [WordPress Trac] #9886: Cannot reliably add query arguments to all WP_Query objects

WordPress Trac wp-trac at lists.automattic.com
Wed May 20 06:23:55 GMT 2009


#9886: Cannot reliably add query arguments to all WP_Query objects
--------------------------+-------------------------------------------------
 Reporter:  westi         |       Owner:  westi
     Type:  defect (bug)  |      Status:  new  
 Priority:  normal        |   Milestone:  2.8  
Component:  Plugins       |     Version:       
 Severity:  normal        |    Keywords:       
--------------------------+-------------------------------------------------

Comment(by westi):

 Example code which shows the bug, put this in a Template file:

 {{{
         <div id="children">
                 <dl>
                 <?php
 query_posts('static=true&posts_per_page=-1&child_of='.$id.'&order=ASC');
 ?>
                 <?php if(have_posts()) : while (have_posts()) :
 the_post(); ?>
                         <?php   $inner_query = new
 WP_Query("post_type=page&posts_per_page=-1&child_of={$id}&order=ASC");
                                                 while
 ($inner_query->have_posts()) : $inner_query->the_post(); ?>
                                         <dt><a href="<?php
 the_permalink();?>"><?php the_title();?>:</a></dt>
                                 <dd style=""><em><?php the_excerpt();
 ?></em></dd>
                 <?php endwhile; endwhile; endif; ?>
                 </dl>
         </div>

 }}}

 Setup the following Page structure:
 {{{
 # Grandparent
     * Child A
           o Grandchild One
           o Grandchild Two
     * Child B
           o Grandchild Four
           o Grandchild Three
 }}}

 Install my Query Child Of plugin from the plugin repo.

 You will get the following incorrect output:
 {{{
     * Child A
     * Child B
     * Child A
     * Child B
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9886#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list