Skip to content Skip to sidebar Skip to footer

How to Exclude Specific Categories from Your Blog Homepage?

You may not like a specific category on your home page. Learn how to Exclude Specific Categories from Your Blog Homepage.

In WordPress, there are various tips and tricks to change the layout and appearance of your website/blog. WordPress comes loaded with plenty of themes and layouts which you can edit and customize as per your business requirements. When you display the latest posts on home page some users prefer to exclude certain categories which are displayed on their blog homepage. You can use a simple technique to achieve this option by editing the functions.php file and creating a filter in it. All you have to do is create a function for excluding some categories in the home page by writing a query. You can find the code snippet as below: How to Exclude Specific Categories from Your Blog Homepage

function exclude_category_home( $query ) {

if ( $query->is_home ) {

$query->set( ‘cat’, ‘-6, -12’ );


return $query;


You can change the category IDs in the query to specific values based on which category you wish to exclude in your blog homepage. Once done you can save the file and add this filter to functions.php file as below:

add_filter( ‘pre_get_posts’, ‘exclude_category_home’ );

When you activate the function through WordPress dashboard and reload your website homepage, you will find that the categories blocked by you will not be displayed under home page. The WordPress dashboard has lot of options for manipulating the website and is similar to control panel found provided by web hosting services. You can modify the default themes by editing the style.css present in the WordPress themes directory.

One of the important advantages of using WordPress to design a website or blog is that it’s absolutely free and you will not be charged for web space or themes.  There are more than 210 default themes and it also allows you to create custom themes. It has various features like Social media integration, custom plugins, mobile platform support, multilingual supports, spam protection etc.

This Pop-up Is Included in the Theme
Best Choice for Creatives
Purchase Now