WordPress.org

Ready to get started?Download WordPress

Forums

How to Exclude posts that belong to a special category? (10 posts)

  1. michuk
    Member
    Posted 7 years ago #

    Here is my case:

    I have a category "News" which groups the news posts (dah!) and which are displayed on a special /news/ page (those news posts may belong to other categories as well).
    I want these posts to be omitted on ANY OTHER blog page.

    The FAQ just deals with excluding posts that belong to ONE SPECIFIC category:
    http://codex.wordpress.org/Template_Tags/query_posts#Exclude_A_Category_From_Your_Home_Page

    Is there a simple way to exclude all posts tat belong to some category (but not necessarily only this one)?

  2. moshu
    Member
    Posted 7 years ago #

    Just curious: if they don't belong to the same "news" catgeory but to more than one cat... how do you display them on that special page? (Page?)

  3. michuk
    Member
    Posted 7 years ago #

    moshu: They all belong to "News" category. Some of them (most of them actually) belong to other categories, additionally. I just display all the posts that belong to "News" on that special page.

    The problem is that I don't want those posts to be included in ANY other page.

  4. moshu
    Member
    Posted 7 years ago #

    This plugin helps you to exclude them from the frontpage (main index) for sure:
    http://ryowebsite.com/?p=46
    It might have other features, too - I don't use it.
    Check it out.

    OK, I just read a bit about it: you can exclude from Archives, from being listed in the sidebar, from search.
    Where else do you want to exclude them?

  5. michuk
    Member
    Posted 7 years ago #

    I'll take a look at it. Actually I need to exclude the category from EVERYTHING. It would be ideal to have a special parameter to pass to a query to NOT EXCLUDE this category, and in all other cases to exclude it. Perhaps writing an own filter would be a better solution for that but I don't know which function to filter in this case...

  6. Samuel B
    moderator
    Posted 7 years ago #

  7. michuk
    Member
    Posted 7 years ago #

    @samboll

    This simply omits the post when already fetched. I need it to work on the database level, not the interface. Otherwise it screws up paging, sorting and all kinds of things. If I have just 1 normal post and 5 "news" posts, then on the home page I will see only this 1 post and link to "previous posts" and this is certainly not what I need.

  8. michuk
    Member
    Posted 7 years ago #

    @moshu:

    I tested the category visibility plugin (http://ryowebsite.com/?p=46) and unfortunately it works the same as the default WordPress category filtering -- it filters out only the posts that belong to ONLY ONE category. If a post belongs to 2 or more categories, and only one of them is selected to be filtered out, it shows the posts anyway, thus making it not useful to me.

  9. michuk
    Member
    Posted 7 years ago #

    So, do you think there is no easy way to do this?

  10. michuk
    Member
    Posted 7 years ago #

    OK I finally decided on creating a custom query. It's well explained here: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
    and works just fine.

    Still, if anyone finds a simpler solution, I'll be glad to hear it (I'm not marking the post as resolved).

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags