Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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();

$wp_query->query('posts_per_page=20'.'&paged='.$paged);
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?

Thanks.

share|improve this question
add comment

1 Answer 1

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

endwhile;
share|improve this answer
add comment

Your Answer

 
discard

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.