• Hi there!

    Just a heads up, I’m very new to WordPress and PHP, so please bare with me.

    I have two loops running on my index.php page, one to display the first post as a full-bleed header and the second to show the rest of the posts with an offset so that the header post isn’t duplicated. My issue is that I have a horizontal sub-navigation bar in the middle of the loops with links to various categories (i.e. /blog/category/product), but after clicking on the link, the posts don’t filter by the category. Instead, every single post loads.

    I noticed that removing the queries associated with each loop fixes the problem, but the queries are essential.

    It may also be more ideal to only run one loop to keep the webpage load time to a minimum, so if anyone knows how to make that happen with the categories sub-navigation, please let me know!

    Here is my code: http://pastebin.com/k2Du5SpT

    Thanks in advance for your help!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    @gabbyhanna – perhaps you’ve solved this and thus your paste was removed?

    Without your code I can only guess that your queries are not picking up the category query var from the main WP query. Instead of custom queries, I think I would look at some sort of if/then logic in your template loop where if it’s the first post in the loop do the header thing then set a flag. Then if the flag is set, the header has been output, so do the other thing instead. Thus you can use the main WP query and still acheive the effect you want.

    If this doesn’t help you, perhaps it’ll help someone down the line getting this thread in search results 🙂

Viewing 1 replies (of 1 total)

The topic ‘Category slug not filtering posts with loop query’ is closed to new replies.