Query String with __not_in

Hello theme.co,

i’ve trying to create an “Query String” Looper that should get me posts with a specific category name but should exclude a custom category.


category_name=k-i-t is a category in the wordpress standard category list.
category 93 is a category in a custom category system (custom category list is created with toolset)

But the query doesn’t exclude the category 93 and show all posts with category_name k-i-t, even if they have category 93 set.

Hi @Regnalf,

Thanks for reaching out!

Would you mind sharing your admin credential so that we can check your setup properly? To do that, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password
  • URL of the page where the query string is located

You can find the Secure Note button at the bottom of your posts.

Thank you.

Credentials in secure note.

Hello @Regnalf,

The given credentials are not working for us.
See the secure note.

In the meantime, please use this query string instead: post_type=post&category_name=k-i-t&category__not_in=93

Kindly let us know how it goes.

Sorry, the query string ist not working. What I would like to achieve is that the posts that have the category “KIT Presented” do not appear in the lower looper because they already appear in the Hero Slider and are therefore seen twice.

Hello @Regnalf,

You are using the wrong query. Since you just want to exclude all posts with the KIT category, you can simply use the Query Builder.

Kindly let us know if this has worked out for you.

I apologize if I have once again caused confusion by my inaccurate information.

It is only about the posts that are provided with the category “K.I.T.”. Whereby some “K.I.T.” posts can “additionally” have the category “KIT Presented” which are defined in the user created category system “Post System”.

Here is an example:

  • Post #1 - :white_check_mark: (WP Post category) “K.I.T.” / :ballot_box_with_check: (Custom Cagtegory “Post System”) “KIT presented”
  • Post #2 - :white_check_mark: (WP Post category) “K.I.T.” / :ballot_box_with_check: (Custom Cagtegory “Post System”) “KIT presented”
  • Post #3 - :white_check_mark: (WP Post category) “K.I.T.” / :white_check_mark: (Custom Cagtegory “Post System”) “KIT presented”

(Custom Cagtegory “Post System”) “KIT presented” Tag ID = 93

Post #1 and #2 should be seen in the looper below. Post #3 should only be visible in the hero slider, because it is “presented”. Otherwise it would be seen twice, in the Hero Slider and in the Looper.

Attention: Currently there is only one post with the category “K.I.T.”, and this post has the category “presented”. So there should be only one post in the hero slider, and below it should be an empty looper.

The problem with the query builder is that I can only use either include or exclude in the taxonomy filter, but not both.

Bildschirmfoto 2021-11-26 um 08.00.15

Therefore I wanted to try it with the query string. If this is not possible with the query string, I could also create a custom looper.

I hope I have now expressed myself clearly and again apologies for the confusion.

Hi @Regnalf,

If you want to exclude and include categories, you need to use the Query String only. I have checked your website and found that the category name KIT is associated with the posts but the 93 category id is associated with any posts.
I would suggest you go through the following article on the category parameter of WordPress main query.

I would also request you specify where we can find the category 93, for further investigation.


The Category Tag 93 (“Kit Präsentiert”) you can find in the custom post category post-system.

I found the tax query in this article too, but if you want to exclude some tax you have to create an array with an operator. I know how to do it in an php WP_Query, but i don’t know if it’s possible in an query string.

Hi Regnalf,

You need to create the array of arguments of the Query and then just use http_build_query function to format it into Query String.

Hope it helps.

Thanks a lot @tristup,

that’s working perfectly. The whole thing ended up in a rather long query string, much longer than I thought it would be and way too long to type in by hand!

Really good tip with the http_build_query( $query ) function, thanks a lot.


Hi @Regnalf,

We’re glad that my colleague was able to help you with your issue. If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.