Support Forums

Support Forums Forums Search & Filter Pro Include AND exclude category

This topic is: not resolved

This topic contains 8 replies, has 3 voices, and was last updated by  Jeroen bakker 1 week, 2 days ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Jeroen bakker

    Hi, In a search form I want to include one category AND exclude one category. the problem is I can only choose either include OR exclude. is there a way to do what I want?

    Trevor Moderator

    You may be able to do it using custom code, but it is not possible in the plugin settings. You would have to use the Edit Query Arguments filter.

    Jeroen bakker

    Hi thansk, I am not a programmer. could you please provide me with an example where one category (a number) is excluded from the from.
    I guess i have to put it then in my functions.php ?
    many thanks
    cheers, jeroen

    Trevor Moderator
    This reply has been marked as private.
    Ross Moderator

    Hi Jeroen

    Sorry for the delay just picking this up now.

    I have a question regarding the logic of what you are trying to do.

    Including and excluding are not technically possible.

    By default, everything is included.

    So if you include a single category, all results will be restricted to what you just included, meaning, every other category will be automatically excluded (in effect), meaning you shouldn’t need to exclude anything else.

    Take this example, a list of categories:


    If I included “Design”, then the search would be limited to only:


    So Blog and Development would be excluded already – and there would be no need exclude anything.

    Does that make sense?


    Jeroen bakker

    Hi ross, I understand what you mean. The problem is that I have about 20 categories and 10 search forms. There are forms where i want to include one category and exlude another, otherwise I have to exclude all categories which is quite some work.. But if there is no other way, I have to rest my case

    Jeroen bakker

    Ross, the exluding way does not work, I have a category aardrijkskunde which is ID 104, if I only include 104 the right results are shown, but if I exlude all categories except 104 (meaning id’s 155,98,157,103,154,139,133,158,156,106,1,101,99,97,140,159,105,100,9,113,102) I have no result at all.
    Hope you can help

    Ross Moderator

    Hi Jeroen

    Is it possible that when you exclude all other categories, that that you get no results, because the results have multiple categories?

    So when you might expect there to be results when excluding all except 104, you don’t get any, because the results that would be in 104, also share some other categories which are in the exclude list?

    Your original question states you want to include one category, and exclude another, surely, just doing an “include” on one category works because it excludes the others?

    If I’m getting confused, please explain with clear example which outlines a few posts, what categories they have, and what settings do / do not work.


    Jeroen bakker

    Hi ross,
    On the page you see a filter which only shows the results from category ‘Aardrijkskunde’. All posts indeed have more than one category.

    When i want to exclude all posts in the results on this page with the category ‘Archive’, I indeed tried to exclude all categories except for ‘Aardrijkskunde’ and ‘Archive’, but that does not work because the postst have more than one category (like you say yourself).

    Do you see any solution to this? So is there any possibility to show results fromn category aardrijkskunde but not from category Archive?


Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.