Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1007378
    goalsarecool
    Participant

    Is there a way to prevent certain blog post categories from showing on the blog page but show in recent posts on the home page?

    Thanks in advance!
    Blake

    #1007437
    Thai
    Moderator

    Hi Blake,

    Please add the following code under functions.php file locates in your child theme:

    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-1,-1347' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );

    Replace 1, 1347 with your category IDs.

    Hope it helps 🙂

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