Tagged: Custom Query
- September 15, 2016 at 12:04 pm #14186Joke PortegiesParticipant
I want to display only the top-level categories, but posts on the sublevels are showing too. I thought I could use a custom query to filter out the subcategories, but now my layout is not loading. This is the syntax I used: meta_key=category__not_in&meta_value=kleding. I tried to use quotes around ‘kleding’ but that gives the same result…
What am I doing wrong?September 15, 2016 at 4:29 pm #14192
The custom query you have written is not in right order. For category you can’t use meta_key. That are for custom fields.
You can use this in custom meta query category__in=123 . Where 123 is the id of your category.
ThanksSeptember 16, 2016 at 7:34 am #14210Joke PortegiesParticipant
Still doesn’t work. The custom query is now the only filter I use to narrow down the posts I want to see, in a 3-column layout. In the Custom Query I put this: category__in=9 . Still keeps loading and not showing…September 19, 2016 at 3:13 am #14240
In that case, can you please send me your wp-admin details with this thread url. I will try to check your category structure and fix it.
Thanks.September 19, 2016 at 2:46 pm #14252Joke PortegiesGuest
Hi, I think I’m a bit further in understanding. At least I have a layout now. But I still don’t know how to filter out posts from the subcategory.
My maincategory is 111 and 112, 113 and 114 are subcategories. You can find my page here: http://www.jannytermeer.nl/Wordpress/test-voor-nieuwe-homepagina/. The only posts I want to see are the posts with the pictures. The other posts are from the subcategories.
I tried this custom query syntax now, trying to filter out the posts from category 112, 113 and 114 (which are the subcategory’s): category__not_in=array(112,113,114). But the posts keep appearing. Again the wrong syntax?
Groete, JokeSeptember 20, 2016 at 2:30 am #14254
Any chance you can try this format ? category__not_in=112,113,114 ? I am sorry about not being sure myself. That was the reason i asked for the wp-admin details, so that i can try and test here.
ThanksSeptember 20, 2016 at 12:32 pm #14270Joke PortegiesGuest
hi Masonry Guy, thank you for your patience. I actually made some printscreens, to show the structure of the main-category and the subcategories, but I could not figure out how to send them with this message. But I got wiser studying the images myself, so I thought I’ld give it another try.
When I use the category__not_in=112,113,114 the result is that my posts with category 112 are filtered out. The other ones are still in.
I think I must drop they idea of filtering out the maincategory. I think I’m going to use the meta_key and meta_values, like I did abusively in the first place. Thank you for thinking with me!September 20, 2016 at 3:01 pm #14271
One of the best idea will be to filter out based in tags if it is applicable for you.
- The forum ‘Pro Version’ is closed to new topics and replies.