Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1310167
    fatcatgraphics
    Participant

    Hi, I want to omit one category from showing up on my blog page. How do i do this?
    This is my site: http://bd2.d9b.myftpupload.com/blog/
    I have a news page and a blog page. So i don’t want the news posts showing up on the blog.

    Thanks for your help. Also if it requires editing the functions.php file can you give me a little direction on how to do this? Do i go into filezilla to edit it and if so do i add the code to the bottom or top?

    Thank you!
    Rena

    #1310620
    Rue Nel
    Moderator

    Hello Rena,

    Thanks for writing in! To resolve your issue and exclude posts with News as the category, please add the following code in your child theme’s functions.php file

    // Exclude posts that has Events and Sermon category from the blog index
    // =============================================================================
    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-13' );
        }
    }
    //add_action( 'pre_get_posts', 'exclude_category' );
    // =============================================================================

    Please make sure that you replace 26 with the correct category ID of News. To know how to get the category ID, please check this out: https://community.theme.co/kb/how-to-locate-category-ids/

    Hope this helps

    #1314390
    fatcatgraphics
    Participant

    Thank you for your help.. you say to replace the 26 with the correct ID. I don’t see a 26 in the code. I see a 13.. The post ID is actually 13 so I left it as is. But I see no change. Does it take time?

    Thanks
    Rena

    #1314417
    Thai
    Moderator

    Hi There,

    Please update the previous code to this:

    // Exclude posts that has Events and Sermon category from the blog index
    // =============================================================================
    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-13' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );
    // =============================================================================

    Hope it helps 🙂

  • <script> jQuery(function($){ $("#no-reply-1310167 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>