The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →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.
#1 Best Overall
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.
- In the editor, open the page or template containing the homepage’s Query Loop.
- Select the Query Loop block and open its block settings.
- Under the query or filters section, choose the category to exclude.
- 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.
Rank #2
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.
Rank #3
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.
Rank #4
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:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallBest Value
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.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
- In the dashboard, go to Posts → Categories and open the category for editing.
- Read the numeric ID in the edit URL, then substitute that number for
12in your code or select the matching category in the Query Loop settings. - Clear any page, object, or CDN cache used by the site.
- Check the homepage for posts in the excluded category, then open the category archive to confirm those posts still exist there.
- 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_postscondition 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()oris_front_page(), and retain theis_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.
Quick Recap
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.

