WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my loop code for index.php . I do not have an archive or category.php right now. This is very basic.

$temp = $wp_query;
global $wp_query;    
$wp_query = new WP_Query();

while ($wp_query->have_posts()) : $wp_query->the_post();

I have about 10 posts split up into different categories.

When I click /category/category-name it just lists all posts rather than filtering by category.

Can someone help me out if they know the solution?


share|improve this question
up vote 2 down vote accepted

You are overwriting the query that loads with the page (which you saved to $temp) - why not just use the one that loads with the page:

while(have_posts()) : the_post();

// put the post here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.