Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep a category off your WordPress homepage, first identify what generates the visible post list. A Query Loop block can exclude the category in the editor; a custom WP_Query can use category__not_in; and the existing main query can be altered with pre_get_posts. These methods remove posts from the targeted listing without deleting them or removing them from their category archive.

Identify which homepage you have

Open Settings → Reading. WordPress can use either the latest-posts index as the front page or a static page. With a static front page, a separate page can be selected for the posts index. The setting determines which content source you need to change; plugins and post-display controls can also modify the result. See the WordPress Settings Reading screen documentation.

Latest posts on the front page

The theme’s home or posts query supplies the list. Use a Query Loop filter if the list is block-based, or adjust the relevant query in code.

A static front page

The page may contain a Query Loop, a theme template, or a plugin-generated listing. Excluding a category from the posts index does not necessarily change a separate static front-page listing, so inspect the component that actually renders the posts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Option 1: filter a Query Loop block

Use this route when the homepage list is a Query Loop block. The block’s settings include category and tag filters, as documented in the Query Loop block guide.

  1. In the editor, open the page or template containing the homepage’s Query Loop.
  2. Select the Query Loop block and open its block settings.
  3. Under the query or filters section, choose the category to exclude.
  4. Save or update the page/template, then view the homepage while logged out or in a private window.

This changes that Query Loop only. Other loops, widgets, archive pages, feeds, and plugin listings keep their own query rules unless you change them separately.

Option 2: exclude the category in a custom WP_Query

If your theme or plugin builds the homepage with its own query, pass the category ID in category__not_in. The official WP_Query reference documents this argument as an array of category IDs. It also documents negative category IDs in the cat argument as an alternative.

Example

$query = new WP_Query( array(
    'category__not_in' => array( 12 ),
) );

Replace 12 with the ID of the category you want to hide. The category ID is available from the category edit screen or in its edit link in the WordPress dashboard.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Important scope check

This argument affects only the WP_Query instance shown. It does not automatically alter the query used by the homepage. Add it to the code that actually renders that list, and account for pagination, ordering, and any other arguments already present.

Option 3: modify the existing home query with pre_get_posts

Use pre_get_posts when you need to change WordPress’s existing main posts query rather than create a new query. WordPress’s pre_get_posts reference shows the pattern of checking the main query and excluding a category.

For the posts index

function exclude_category_from_home_query( $query ) {
    if ( ! is_admin() && $query->is_home() && $query->is_main_query() ) {
        $query->set( 'category__not_in', array( 12 ) );
    }
}
add_action( 'pre_get_posts', 'exclude_category_from_home_query' );

Place the code in a site-specific plugin or a child theme’s functions.php, rather than editing a parent theme that can be overwritten by an update. Test after adding it, and remove or revise it if another plugin deliberately changes the same query.

For a front page conditional

is_home() identifies the posts index; it is not interchangeable with is_front_page(). WordPress documents is_front_page() for the site’s front page. If a static page is the front page and a different page is the posts index, choose the conditional that matches the listing you intend to change. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function exclude_category_from_front_query( $query ) {
    if ( ! is_admin() && $query->is_front_page() && $query->is_main_query() ) {
        $query->set( 'category__not_in', array( 12 ) );
    }
}
add_action( 'pre_get_posts', 'exclude_category_from_front_query' );

Use this only when the main query is the one producing the front-page posts. A static page whose posts come from a block, template, or plugin may require that component’s own filter instead.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which method should you choose?

Method Homepage content source Code required What it changes
Query Loop filter A Query Loop block in a page or template No That individual block
WP_Query with category__not_in A custom query written by a theme or plugin Yes The specific custom query
pre_get_posts An existing WordPress main query Yes The matching main query, when its condition is correct

Start with the block setting when a Query Loop visibly controls the list. Use pre_get_posts for the relevant existing main query. Use a standalone WP_Query only when the homepage is actually rendered from that custom query.

Find the category ID and verify the result

  1. In the dashboard, go to Posts → Categories and open the category for editing.
  2. Read the numeric ID in the edit URL, then substitute that number for 12 in your code or select the matching category in the Query Loop settings.
  3. Clear any page, object, or CDN cache used by the site.
  4. Check the homepage for posts in the excluded category, then open the category archive to confirm those posts still exist there.
  5. Check the posts index separately if the site uses a static front page, and inspect any secondary loops such as featured-post sections or widgets.

Common reasons the category still appears

  • The wrong query was changed: a static front page, a separate posts page, and a custom template can each use different queries.
  • The loop is a block or plugin output: a pre_get_posts condition cannot rewrite a separately constructed query that ignores the main query.
  • The condition is too broad or too narrow: verify whether the target is is_home() or is_front_page(), and retain the is_main_query() and front-end checks where appropriate.
  • Caching masks the change: purge site and CDN caches before judging the result.
  • Another listing is visible: a featured, recent, or related-post section may have its own category settings and query.

What exclusion does—and does not do

Category exclusion changes which posts a particular listing retrieves. It does not delete posts, unpublish them, remove their category archive, or automatically hide them from every other query on the site. Apply the filter separately wherever the category must be omitted.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.