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

To keep a category’s posts off your WordPress homepage, first identify what generates the homepage listing. Filter the Query Loop block if the posts appear in a block; adjust the relevant query if the theme or custom code generates the listing. The change applies to that display query, not automatically to every place those posts appear.

First identify which page and query you need to change

In the WordPress dashboard, open Settings > Reading. The “Your homepage displays” setting shows whether the site uses its latest posts or a static page as the front page. A static front page can also have a separate Posts page. See WordPress’s Reading Settings documentation.

If the homepage shows the latest posts, the output is driven by a posts query. If it is a static page, the visible listing may instead be assembled with a Query Loop block, a theme template, or a plugin. Identify the element that produces the listing before choosing a fix: changing a query that does not power the visible listing will have no effect.

Choose the approach that matches the homepage listing

Homepage listing Approach Best fit
Query Loop block on a page or template Set the block’s category filter Use when the visible posts are rendered by that block; no PHP is needed.
Existing main posts query Use pre_get_posts and a matching query condition Use when you need to alter the site’s relevant existing posts query.
Custom query created by the theme or code Pass category__not_in to that WP_Query Use only when that custom query actually renders the homepage listing.

Filter a Query Loop block

When the homepage listing is a Query Loop block, select the block in the editor and use its settings to filter the displayed posts by category. The block also supports filtering by tag. The exact controls can depend on the editor context; WordPress documents the available options in its Query Loop block guide.

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

This setting controls posts displayed by that block. It is not a global category exclusion, so it does not automatically change other Query Loop blocks or archives.

Exclude a category from a custom query

For a custom WP_Query, WordPress documents category__not_in as an array of category IDs to exclude. For example, this query excludes category ID 12 from its results:

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

Replace 12 with the ID of the category you want to exclude. This affects only the query shown; it does not change the site’s homepage unless that custom query is what renders the homepage listing. The WP_Query reference also documents using a negative category ID with the cat argument to exclude a category.

Adjust the relevant main query with pre_get_posts

If the homepage listing uses WordPress’s existing main posts query, the pre_get_posts hook lets code change its query arguments. WordPress’s example checks that the query is both the home query and the main query before modifying it. A category-exclusion adaptation is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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' );

Change 12 to the category ID you want excluded. The checks matter: without targeting the intended query, code may affect other listings or the wrong page. WordPress documents the hook and its query-targeting pattern in the pre_get_posts reference.

is_home() and is_front_page() are not interchangeable. In WordPress terminology, the home query is the posts index; the front page is the site’s front page. When a static page is set as the front page and a different page is selected for posts, the relevant query may be the Posts page rather than the static front page. WordPress documents is_front_page() separately. Match the condition to the page and query that actually produce the listing.

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

Check the result and troubleshoot a no-change outcome

  1. Confirm the category ID. Use the ID for the category to exclude in the block setting or code.
  2. Confirm what renders the listing. If the homepage is static, inspect its Query Loop block, template, or plugin rather than assuming the default posts query supplies it.
  3. Confirm the query condition. For pre_get_posts, make sure the selected condition matches the posts index or front-page arrangement on your site.
  4. Check the visible homepage again. If the category still appears, the code or block setting may be changing a different listing from the one you are viewing.

WordPress notes that plugins affecting static front pages or post-display controls can change how Reading Settings work. A theme template or plugin may also supply a separate query, in which case the custom-query approach applies only if that is the query rendering the posts.

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.