WordPress.org

Ready to get started?Download WordPress

Forums

Exclude specific category posts except for stickies (4 posts)

  1. denutza
    Member
    Posted 1 year ago #

    Have not been able to find this specific answer through extensive searching.

    In my main home page loop, I want to exclude a category of posts, except if a post in that category is a sticky!

    <?php query_posts($query_string . '&cat=-6'); ?>

    That will exclude all the posts in the category.

    So the logic would be:exclude if category=6 AND !sticky

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    I just tested this query and the sticky posts from category 6 are still showing on top of all other posts (without category 6). Do you have any loops before the main loop?

  3. denutza
    Member
    Posted 1 year ago #

    No other loops or queries before this.

    I would think that's odd yours even showed the stickies, without additional code.

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    Is this on a static front page?

    Can you paste and submit the full code into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.