How To Hide or Remove Categories from the Homepage on WordPress

Most of the WordPress websites show the latest posts on the homepage. The reason behind it is the desire of most of the users to see the new articles being featured there. The recent content are being classified into several categories. However, there are times when you don’t want to see some of them. For the beginners, it might look impossible to do. But in reality, it can be done pretty easily. In this article, you will find different ways to excluding categories from the homepage on WordPress website.

Modifying the functions.php File

The loop is the code the WordPress uses to display the content on the website. Every WordPress theme makes the use of it. You can modify it to exclude specific categories on the homepage. Here are the steps:

Step 1:

Go to our functions.php file

Step 2:

If you have two categories of post (uncategorized ‘3’ and another ‘1347’), add the following codes there:

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

Here ‘3’ and ‘1347’ are IDs. If you are facing trouble to find them, use the following method:

Finding Category IDs

Step 1:

Navigate to Posts > Categories.

Step 2:

Put the cursor on your desired category.

Step 3:

Take a look at the number beside category&tag_id within the destination page URL. It is your category ID.

How To Hide or Remove Categories from the Homepage on WordPress

Using Ultimate Category Excluder

Ultimate Category Excluder is a popular plugin for removing categories from the home page. The method of exclusion is very easy. You just need to select the categories that you want to remove. It can be very useful if you are not comfortable with editing the files of your WordPress theme.

How To Hide or Remove Categories from the Homepage on WordPress

There is an issue with Ultimate Category Excluder. Right now, you cannot use the plugin to remove Categories from Category Widget. But if you really need to do it, you have to modify your theme’s function.php file. The codes look quite similar to the ones mentioned in the second step of Modifying WordPress Loop.

function exclude_category_widget($args){    // Add the category IDs you want to exclude, separated by commas    $args["exclude"] = "-3,-1347";     return $args;}add_filter("widget_categories_args","exclude_category_widget");

Conclusion

In this article, you have seen two different ways of hiding or removing categories from your WordPress homepage. Right now, most of the users prefer to use Ultimate Category Excluder. However, if you have no issues dealing with codes, you can follow the first way to exclude categories pretty easily.

Check out these top 3 WordPress hosting services:

HostArmada
$1.79 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.03 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Configure WordPress Page Caching

A savvy website owner understand how important it is to have a website with a qu
4 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Secure Your WordPress Website

Millions of websites get hacked every year and many people consider WordPres
5 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Create a WordPress Child Theme

Customizing your WordPress theme but want to be extremely safe? Don’t worry. W
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Fix File and Folder Permissions Errors in WordPress

It's so frustrating when you receive an error while updating your website. File
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top