Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#8798 closed defect (bug) (invalid)

query_posts pulls all post categories instead of category specified.

Reported by: cynthea's profile cynthea Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords:
Focuses: Cc:

Description

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

Change History (4)

#1 @filosofo
15 years ago

Are you sure that you have the category IDs correct? The exact code works fine for me with my corresponding categories, but I notice when I try appending ?cat=7 or other ID numbers to your site, which should redirect to those categories, it doesn't redirect.

That says to me that something else is going on here; perhaps you have the wrong numbers or a plugin is interfering.

#2 @cynthea
15 years ago

I've double-checked the cat IDs. Those are correct. I will try deactivating all of my plugins and see if it works.

#3 @cynthea
15 years ago

Yup, a plugin is interfering. I will post here when I figure out which one it is.

#4 @Viper007Bond
15 years ago

  • Milestone 2.8 deleted
  • Resolution set to invalid
  • Status changed from new to closed

By reporter's own admission a plugin was at fault. Reopen if found to be otherwise.

Note: See TracTickets for help on using tickets.