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?


1 Answer 1


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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