[Support request] Remove category from blog page

Home Forums Support [Support request] Remove category from blog page

Home Forums Support Remove category from blog page

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1279671
    Nimie

    I would like to keep one category from displaying on the blog page. I tried this:
    .category-uncategorized .entry-meta {
    display:none;
    }

    and this
    function exclude_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( ‘cat’, ‘-1’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘exclude_category’ );

    #1280055
    Leo
    Staff
    Customer Support

    Hi there,

    Just to make sure, you are trying to remove a certain category from the posts loop?

    If so this is the code you’d need:
    https://docs.generatepress.com/article/exclude-categories-from-posts-page/

    Can you make sure that the category ID is correct?

    #1280066
    Nimie

    I tried it and checked the category id. Still not working. Could there be a conflict?

    #1280067
    Leo
    Staff
    Customer Support

    How are you adding that code?

    One of these methods?
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1280068
    Nimie

    To the child theme functions php

    #1280072
    Leo
    Staff
    Customer Support

    I just tested the code in Code Snippets and it worked for me.

    Can you give that a shot first?

    #1280085
    Nimie

    Not working. I have used it on other sites with no problem. All cache is deactivated.

    #1280113
    Leo
    Staff
    Customer Support

    I have used it on other sites with no problem.

    Then it must be something specific to this site.

    Do you another function that might be conflicting?

    You might have to spend a little more time trying to debug this as we know that the code works.

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