• Skip to main content
  • Skip to primary sidebar

Purely Supplemental Hub

Just The Tech, News, and Info We Deem To Post

  • WordPress
  • Marketing
  • Business
  • Computing
  • Security
  • Publicity
  • Resources
  • WHATEVS

Exclude categories from blog

Add the following code to your theme’s function.php file, or a functionality plugin to modify to exclude categories from your WordPress Blog Page.

/** Exclude certain category from posts */
add_action( 'pre_get_posts', 'be_exclude_category_from_blog' );
function be_exclude_category_from_blog( $query ) {

    if( $query->is_main_query() && $query->is_home() ) {
        $query->set( 'cat', '-XX' );
    }
}

Filed Under: Code Snippets Tagged With: Code, WP Core

Reader Interactions

Share Your Two Cents Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

© Copyright Jack Alltrade & Associates 2026 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates