Archived topic
Hide Category from sidebar menu
5 replies · Started by Gevorg on December 14, 2018
Hello,
I am trying to hide one category from displaying in the drop-down menu on the sidebar.
I looked at some previous discussions here and added the following code
add_filter('pre_get_posts', 'excludeCat');
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '69');
}
return $query;
}
But it gives some errors and not saving in the custom CSS.
Could you please guide?
Thank you
Hi there,
The code you have would exclude a certain category from the blog archive page.
The category widget is coming from WordPress and not controlled by GP. I did find this that might be worth trying:
https://wordpress.stackexchange.com/a/253170
The code would be PHP.
Let me know if this helps :)
Hi Leo,
I tried it but it still gives an error.
Make sure you're adding it using one of these methods, as it's not CSS: https://docs.generatepress.com/article/adding-php/
Ok, I figured it. Thank you again for your support!
Glad we could help!