Archived topic
Excluding category on blog site
11 replies · Started by Erika on April 11, 2022
Hi David,
I´d like to exclude the category "kundenstimmen" on the blog-site which was created with block elements. I used the code snippet from the topic #2175464, category ID is 27, so I have -27 in the code. I cleared all caches, however, the category is still shown, could you take a look?
Thanks, Erika
Hi there,
can you share a link to the topic where you got the Code Snippet ? If you right click and copy the #2175464 on that topic it will give you the URL...
Can you try this code instead?
https://docs.generatepress.com/article/exclude-categories-from-posts-page/
If it still doesn't work, can you disable the block element content template and see if that works?
Hi Leo,
no, it doesn´t work, either way :(
Which works is if I disable the Blog site as Blog site in the WP settings and I add a recent post widget with the category excluded to the Blog site, but that would need a lot of css to style and I really like the way you create block element templates... Much nicer. Actually if we had a way to create a recent post template with the possibility to choose or exclude categories, that would be awesome. Till then, do you have another suggestion for me?
Erika
Hi Erika,
The code Leo provided should work.
Can you try clearing cache and disable cache plugin?
Make sure you clear your cache plugin and browser cache as well.
Hi Ying, I did both. No change.
I just tested the code and it works well.
So can you disable all plugins except GP premium to test the code?
If you have any other custom functions, please disable them as well.
And can you share the exact code you are using? Please use the code tag to wrap the code so we can check the format.
Obviously I do something wrong. Can I give you a login and you take a look? Might be faster.
I logged in and activate the code in code snippet plugin and it seems working well, I don't see the posts from category Kundenstimmen on the blog page.
https://www.screencast.com/t/8pXi6mzz
Hi Ying, yes, I see it working. I also see what I missed. Thank you so much, you are awesome! Erika
No problem! Glad it works now :)