[Resolved] Hide Category from sidebar menu

Home Forums Support [Resolved] Hide Category from sidebar menu

Home Forums Support Hide Category from sidebar menu

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #757086
    Gevorg

    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

    #757104
    Leo
    Staff
    Customer Support

    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 🙂

    #757164
    Gevorg

    Hi Leo,

    I tried it but it still gives an error.

    #757173
    Tom
    Lead Developer
    Lead Developer

    Make sure you’re adding it using one of these methods, as it’s not CSS: https://docs.generatepress.com/article/adding-php/

    #757175
    Gevorg

    Ok, I figured it. Thank you again for your support!

    #757177
    Leo
    Staff
    Customer Support

    Glad we could help!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.