The Ultimate Guide To Hide or Remove a Category in WordPress

  • By Tammy Clark
  • 28-07-2021
  • Web Design
wordpress category

Categories handle content organization for your WordPress site. By default, WordPress displays posts from all categories on your homepage. Thanks to this feature, visitors can find what they’re looking for with ease.

However, some categories shouldn't appear on the homepage for a few reasons. They can be private content for premium members or simply a list of outdated posts. That’s why you need to search for a way to hide specific categories from your WordPress site.

In today’s post, we will explain 2 main reasons why you should hide or remove categories in WordPress. The following section will guide you on how to exclude them from WordPress, both manually and using plugins.

Reasons to Exclude a Category from WordPress Homepage

There are two main reasons explaining why removing a category from WordPress should be taken into consideration: hiding outdated content and creating private content for members.

Hiding Outdated Content Categories from the Homepage

The longer you’ve worked with your website, the more categories you’ve created. They can be additional categories for new products or new features. Sometimes, you need to reorganize categories on your homepage to show important or latest posts only.

Outdated categories can cause enormous difficulties for readers in updating with your latest content. What's more, too many unnecessary categories will directly affect the site loading speed. So, excluding categories plays a crucial role in leveraging your website and at the same time helping visitors effortlessly approach your important content.

Creating Private Content for Premium or Paid Members
If you’re running a membership site or selling online courses, making some categories private on your site is a must. It can prevent strangers from attempting to access your content or products only made for your internal members.

WordPress, by default, does not let you hide categories from your homepage. That means, unwanted posts or pages still appear to all visitors. So, we’ll walk you through 2 simple ways to hide a category in WordPress.

2 Methods to Hide Categories from the Homepage in WordPress

Exclude a Category from WordPress Homepage Using Code
This method requires you to add code to your WordPress functions.php file. To begin with, you need the category ID of which you want to hide.
Step 1: Head to your WordPress dashboard
Step 2: Click on Categories under the Posts section
Step 3: Hover your desired category to get its ID in the URL at the bottom left corner of the page
Step 4: Open Appearance > Theme Editor in the navigation menu
Step 5: Insert the following code to your theme’s “functions.php” file.

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

add_filter( 'pre_get_posts', 'exclude_category_home' );

In the $query->set( ‘cat’, ‘-19’ ); you have to replace “-19” with your category ID. When that’s done, all the posts belonging to that category will be hidden immediately.

In fact, this method is not preferable to most WordPress users due to its complexity. They have to back up the site or create a child theme and edit the function.php file there otherwise it will affect the whole site performance.

We highly recommend taking advantage of WordPress plugins which free you from touching a piece of code.

Restrict Access to Categories with PPWP Pro and Access Level Extension
Password Protect WordPress (PPWP) Pro proves the up-to-par categories protection plugin. It also boasts an intuitive, easy-to-use User Interface (UI), making it a solid choice for any skill level.

PPWP Pro will keep all posts in your WordPress category private using passwords. To be more clear, we will guide you through the 4 steps below on how to get started with the plugin.

Step 1: Install the PPWP plugin, both Free and Pro versions.
Step 2: Go to Posts > Categories in your WordPress dashboard.
Step 3: Select the certain category that you want to protect.
Step 4: Simply click on the Protect category button in the Password Protection column.

As a result, all posts under that category become invisible to the public. Whenever users get access to any posts belonging to that category, they are forced to fill in a password form.

Once protected, your content won’t be indexed by search crawlers or appear on search results.

Out of the box, PPWP Pro allows you to make the entire WordPress site private with one or multiple passwords. It’s possible for you to exclude some pages from the site-wide protection too.

Additionally, the PPWP Access Levels extension gives you the ability to protect product categories as well as limit access by levels and user roles. This add-on stays top-of-mind way to password protect your content.

Protect WordPress Categories by Levels
Access Levels extension allows you to protect the entire post categories as well as multiple WooCommerce product categories at the same time. Besides, it allows you to auto-protect new posts under any selected categories of the base level. You can set different access levels for each base or unlimited passwords for any particular level.

Keep reading to follow 3 easy steps to hide WordPress categories by levels using PPWP Pro Access Levels extension.

Step 1: Create a base

Make sure you install and activate the PPWP Access Levels extension. An extra section will be automatically added to the Password Protect WordPress menu on your sidebar. Click on Access Levels to secure certain categories.

Then, you'll reach Access Levels Management. Head to Add New Base and a popup window will appear to add a base name.

Step 2: Choose categories and classify them into levels

It’s time to select post types to protect in the Actions column. Posts, Products, or any other custom post type can be hidden, too.

In this step, you'll be able to decide the levels of your categories. Level 1 will be lower permission than level 2.

Step 3: Create Access Levels passwords
In the tab of Add New Password, you need to enter your password and its information such as levels, type (global or user roles), usage limit, and expiration time.

In case you want to change your passwords, return the Manage Passwords tab. This shows you a list of all your passwords and their status.

Keep Your WordPress Categories Private
Sorting the content into different categories will help visitors look for content more quickly. However, you shouldn’t let too many categories interrupt the development of your website or the navigation of your readers.

This article provides you with 2 methods to hide your WordPress categories. You can either choose to do it manually or install a plugin and let it handle the task.

Please leave a comment below if you have any questions about categories in WordPress.

Share It

Author

Tammy Clark

Tammy Clark is a young and enthusiastic blogger who is passionate about WordPress development and content protection. She enjoys exploring the world through cuisine.

Recent Blogs

back to top