How to Hide or Exclude Specific Categories from Your WordPress Homepage
Content
Many WordPress users want to curate their homepage content by excluding posts from certain categories. This is a common request, whether to hide an "Announcements" category, filter out test posts, or simply create a more focused front page experience.
Why This Happens
By default, WordPress displays your most recent posts from all categories on the homepage. The theme itself does not typically include a built-in setting for this, as it follows the standard WordPress loop that pulls in all posts. Therefore, achieving this requires modifying the query that fetches the posts.
Common Solutions
1. Using the Blocksy Posts Shortcode (Recommended)
A straightforward method that doesn't require custom code is to use the [blocksy_posts] shortcode. This powerful shortcode allows you to create a custom query for your homepage.
- Create a new page and set it as your homepage under Settings > Reading.
- In the page editor, use the following shortcode structure:
Replace[blocksy_posts exclude_term_ids="CATEGORY_ID"]CATEGORY_IDwith the actual ID of the category you wish to exclude. You can find the category ID by going to Posts > Categories and looking at the tag_ID in the browser's address bar when you hover over the edit link for that category. - To exclude multiple categories, separate the IDs with commas:
exclude_term_ids="4,7,12".
2. Using a Plugin
For users who prefer a graphical interface, several WordPress plugins can add this functionality. Plugins like "Ultimate Category Excluder" or "WP Hide Post" allow you to easily select categories to hide from your homepage, archives, or feeds through a simple settings panel. This is a good option if you are not comfortable editing code.
3. Using Custom Code (Advanced)
For developers or those comfortable with adding code to their site, you can modify the main WordPress query using the pre_get_posts hook. Add the following code to your child theme's functions.php file:
function bugwp_exclude_category_home( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-4' ); // Exclude category with ID 4
}
}
add_action( 'pre_get_posts', 'bugwp_exclude_category_home' );
Important: Always use a child theme when adding custom code to avoid losing your changes during theme updates.
Conclusion
Excluding a category from your homepage is a common customization that is not handled by a default theme setting. The most user-friendly method is to leverage the [blocksy_posts] shortcode, while plugins offer a good alternative for those who want a settings-based approach. For advanced control, custom code provides the most flexibility.
Related Support Threads Support
-
How to vertically center the titles in a category?https://wordpress.org/support/topic/how-to-vertically-center-the-titles-in-a-category/
-
Default Featured Image Problem category/tag Pageshttps://wordpress.org/support/topic/default-featured-image-problem-category-tag-pages/
-
little css problemhttps://wordpress.org/support/topic/little-css-problem-2/
-
Links are not crawlablehttps://wordpress.org/support/topic/links-are-not-crawlable-10/
-
h3 related pageshttps://wordpress.org/support/topic/h3-related-pages/
-
GSC sends warningshttps://wordpress.org/support/topic/gsc-sends-warnings/
-
Header font sizehttps://wordpress.org/support/topic/header-font-size-5/
-
previous calendar monthshttps://wordpress.org/support/topic/previous-calendar-months/
-
Category page header layouthttps://wordpress.org/support/topic/category-page-header-layout/
-
Header font sizehttps://wordpress.org/support/topic/header-font-size-4/
-
Headhttps://wordpress.org/support/topic/head-4/
-
Errorhttps://wordpress.org/support/topic/error-1733/
-
Find in product category texthttps://wordpress.org/support/topic/find-in-product-category-text/
-
custom fieldshttps://wordpress.org/support/topic/custom-fields-413/
-
email field in comment box is small in sizehttps://wordpress.org/support/topic/email-field-in-comment-box-is-small-in-size/
-
Store linkhttps://wordpress.org/support/topic/store-link/
-
Hide a Categoryhttps://wordpress.org/support/topic/hide-a-category-5/
-
Bug in Advanced Posts is backhttps://wordpress.org/support/topic/bug-in-advanced-posts-is-back/
-
Error in category headerhttps://wordpress.org/support/topic/error-in-category-header/
-
Move Category Description below List of Posts navigationhttps://wordpress.org/support/topic/move-category-description-below-list-of-posts-navigation/
-
How to highlight only the primary category in the menu?https://wordpress.org/support/topic/how-to-highlight-only-the-primary-category-in-the-menu/
-
Captalizehttps://wordpress.org/support/topic/captalize/
-
Unable to see the category that I have addedhttps://wordpress.org/support/topic/unable-to-see-the-category-that-i-have-added/
-
Image in Categories – product reviwshttps://wordpress.org/support/topic/image-in-categories-product-reviws/
-
Category Archive Page Post Not Visiblehttps://wordpress.org/support/topic/category-archive-page-post-not-visible/
-
blog category colorhttps://wordpress.org/support/topic/blog-category-color/
-
Sorry, delete thishttps://wordpress.org/support/topic/after-updating-duplicates-products-in-search-results-in-both-language/