[wp-trac] [WordPress Trac] #8798: query_posts pulls all post categories instead of category specified.

WordPress Trac wp-trac at lists.automattic.com
Sun Jan 4 21:06:39 GMT 2009


#8798: query_posts pulls all post categories instead of category specified.
--------------------------+-------------------------------------------------
 Reporter:  cynthea       |       Owner:  anonymous
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  2.8      
Component:  Template      |     Version:  2.7      
 Severity:  normal        |    Keywords:           
--------------------------+-------------------------------------------------
 I recently upgraded to 2.7 and believe query_posts tries to pull all
 published posts instead of the category I have specified.

 Here is the code I was using:


 {{{
 ?php
 /*
 Template Name: Books
 */
 ?>

 <?php get_header(); ?>

         <div id="content_box">

                 <?php include (TEMPLATEPATH . '/l_sidebar.php'); ?>

                 <div id="content" class="pages">

                         <h2><?php the_title(); ?></h2>
                         <div class="entry">

                         <h3>2009 Winter</h3>
                         <?php query_posts('cat=55'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>


                         <h3>2009 Spring</h3>
                         <?php query_posts('cat=7'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>

                         <h3>2009 Summer</h3>
                         <?php query_posts('cat=7'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>


                         <h3>2009 Fall</h3>
                         <?php query_posts('cat=9'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>


                         <h3>2010 Winter</h3>
                         <?php query_posts('cat=59'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>


                         <h3>2010 Spring</h3>
                         <?php query_posts('cat=56'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>


                         <h3>2010 Summer</h3>
                         <?php query_posts('cat=57'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>


                         <h3>2010 Fall</h3>
                         <?php query_posts('cat=58'.'&order=ASC'); ?>

                         <?php while (have_posts()) : the_post(); ?>
                         <ul>
                         <a href="<?php the_permalink() ?>" rel="bookmark"
 title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                         </ul>
                         <?php endwhile;?>



 </div>
                         <div class="clear rule"></div>



                         <div class="clear"></div>

                 </div>

                 <?php include (TEMPLATEPATH . '/r_sidebar.php'); ?>

         </div>

 <?php get_footer(); ?>
 }}}

 This page can be viewed here: http://www.authorsnow.com/books.  As you can
 see it is displaying everything under the sun, instead of the posts in the
 specified categories.

 This page used to work when I was on WP 2.6.3

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8798>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list