WordPress

How to Exclude Specific Category Posts From Your WordPress Home Page

If you want to exclude specific category/categories posts from your WordPress home page, then this article is for you.

By default WordPress doesn’t allow the user’s to exclude a category posts from displaying on home page.

So here i will teach you the two methods to exclude a specific category posts from your WordPress home page.

let’s Start.

1: Exclude Category from Home Page Using Plugin

You can exclude specific category posts from home page by downloading Ultimate Category Excluder plugin.

After download, install & activate the plugin. Then go to Settings → Category Excluder

This plugin will display all the categories of your site.

Now check the categories under ‘Exclude from Front Page’ which you want to exclude from home page.

This plugin also allows you to exclude specific categories from feeds, archives and search result.

After categories checked, click on the Update button.

Now the checked categories posts will not shows on your site home page.

2: Exclude Category from Home Page Using Code

In this method you have to add a piece of code to your theme, and you will be able to exclude specific category posts from your home page.

Add the below code to your theme functions.php or site-specific plugin.

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

Its important to replace the ID (-26) with your category ID and don’t forget the (-) sign with ID.

If you don’t know how to find category ID, read it it will guide you to find category ID.

You can also exclude multiple categories from your home page, for this you have to add comma separate category ID’s in the above code.

For example : (-55,-6,-12)

{it will exclude categories from your home page, which has 55, 6 and 12 ID}

If you find this tutorial helpful, then please Subscribe to our YouTube Channel for video tutorials, and share this article on social media.

Syed Kazim Ali Shah

A Blogger, a full-stack web developer, and the CTO of WebPlover Ltd, Kazim Shah is passionate about coding, development, and SaaS applications since 2014. With an extensive career in freelancing since 2016, he has garnered invaluable experience in the realms of web development and digital entrepreneurship. Through his blogs, he shares insights, tips, and strategies to navigate the dynamic digital landscape successfully. Feel free to reach out to him at kazimshah130@gmail.com or connect on +92 333 9081 488.

Recent Posts

How to Remove Photopea Ads Sidebar and Make it Full Width

In this article, I will share a trick to remove advertisement banners and the sidebar…

3 years ago

Color Theory for Designers – Understand Material Design Colors

Color plays an essential role in design and everyday life. It can draw your attention…

3 years ago

WhatsApp vs Telegram vs Signal – What should you use | Complete Guide

Have you ever been creeped out by an ad appearing in your social media feed…

3 years ago

Best Image Format for Your Website. JPEG vs PNG vs GIF vs SVG

Imagine you have just finished working on your favorite image-editing program and your masterpiece is…

4 years ago

How to Highlight Current Active Page Link in WordPress [with Pictures]

If you want to highlight the current active page link anywhere in your WordPress website…

4 years ago

Solution for Clipboard not Working in Android 10

Hey, guys! All of you who were using any clipboard on their mobile phones must…

4 years ago