Family Encyclopedia >> Electronics

How to Exclude a Specific Category from Your WordPress Homepage (2 Proven Methods)

Want to keep certain posts off your WordPress homepage? By default, WordPress pulls in posts from all categories. But as seasoned WordPress experts, we've seen how excluding specific ones can streamline your site's front page. In this guide, we'll walk you through two reliable methods to exclude categories effortlessly.

How to Exclude a Specific Category from Your WordPress Homepage (2 Proven Methods)

Why Exclude Categories from Your Homepage?

WordPress excels at organizing content with categories and tags. Often, you'll reserve a category for non-blog content like promotions or resources that don't belong on the main page. Without exclusion, these posts clutter your homepage, archives, or even search results.

We'll cover a no-code plugin method and a custom code approach—pick what fits your setup.

Method 1: Use the Ultimate Category Excluder Plugin

Start by installing and activating the Ultimate Category Excluder plugin. For step-by-step installation, see our guide on adding WordPress plugins.

Head to Settings » Excluder Category. You'll see all your site's categories listed.

How to Exclude a Specific Category from Your WordPress Homepage (2 Proven Methods)

Check the boxes for categories under "Exclude from first page." You can also opt to hide them from RSS feeds, archives, or search.

How to Exclude a Specific Category from Your WordPress Homepage (2 Proven Methods)

Hit Update to save. Refresh your homepage—the selected categories' posts will now be gone.

Method 2: Exclude Categories with Code (For Developers)

This requires editing files, so back up first. If you're new to code, check our beginner's guide to adding snippets in WordPress.

Add this to your theme's functions.php file or a site-specific plugin:

function exclude_category_home( $query ) {
    if ( $query->is_home() ) {
        $query->set( 'cat', '-5' );
    }
    return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );

Replace -5 with your category ID (include the minus sign to exclude). Find IDs via our category ID guide.

Note: Always use a leading minus (-) before the ID.

For multiple categories:

function exclude_category_home( $query ) {
    if ( $query->is_home() ) {
        $query->set( 'cat', '-5,-9,-23' );
    }
    return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );

Swap in your IDs, and your homepage will exclude them seamlessly.

These methods have powered cleaner homepages for countless sites we've optimized. For more, explore our top category plugins and hacks.

Subscribe to our YouTube channel for video tutorials. Follow us on Twitter and Facebook for tips.