Along with tags, categories prove one of the most effective ways to organize and sort out your related WordPress posts. Visitors can scan through the category and read all related articles easily.
The Blog on each website can include multiple categories. However, you sometimes might not want all of them to be shown publicly. The main reason comes to grouping outdated posts into a category and hiding it from readers. What’s more, you provide premium products for specific customers and don’t want others to view or make purchases.
Hiding a WordPress category is not a simple task, and WordPress doesn’t offer any built-in feature to support this function. In this post, we’re going to discuss common questions and concerns about hiding WordPress categories so that you can have better ideas about what you need to do.
#1 How do you hide a category in WordPress?
There are two separate paths you can take to exclude a specific category from your WordPress homepage. If you’re a coding wiz, add code to your custom-function.php file. Installing a plugin to simplify the category exclusion process is also recommended.
Method 1: Exclude a category using code
Follow the steps below to hide a category for from your Homepage
- Go to Appearance → Editor in your WordPress dashboard
- In the Select theme to edit, choose your actual theme number
- Open to edit the custom-function.php file
- Head to Posts then Categories underneath to get the category ID before editing
- Hover over the desired category name to get its ID
- Add this code to the very end of the file before closing php tag ?>, and replace 18 with your category ID
function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-18' ); } } add_action( 'pre_get_posts', 'exclude_category' );
- Click the Update file button to save changes
- Separate the comma in the code to exclude 2 or more categories
$query->set( 'cat', '-6,-7' );
Method 2: Exclude a category using a plugin
Firstly, install the Ultimate Category Excluder plugin. Then, take the following steps:
- Head to Settings → Category Excluder
- Click on the category name you want to hide
- Press Update to save settings
Now you can visit your website to ensure that the posts from the selected categories are excluded from the front page.
#2 How do you remove the “Uncategorized” category?
Once published, all your WordPress blog posts are automatically categorized as “Uncategorized”. If you keep forgetting to categorize posts, the site will be in a mess and doesn’t look professional.
You can either change the default category, from Uncategorized to any other categories you want. It’s possible for you to remove WooCommerce Uncategorized category too. Refer to our useful article 2 Ways to Remove “Uncategorized” Category in WordPress to know the steps.
#3 How do I password protect WordPress categories?
WordPress offers a built-in feature allowing you to password protect individual pages and posts but categories. You can install Password Protect WordPress Pro plugin to make a category private with a password.
Follow these steps to password protect a category:
- Head to Categories under Posts in your WordPress dashboard
- Choose the category you want to password protect
- Click on Protect category in the Password Protection column
Once password protected, all posts under that category will be automatically secured with passwords.
#4 How can you hide tags on WordPress?
Similar to categories, tags also help categorize your WordPress posts as well as improving search engine optimization. In case you don’t want to display tags at the end of the post, refer the guides below:
- Login to WordPress dashboard and navigate to Appearance → Customize
- Scroll down until you see Additional CSS option
- Enter this code
.tags-links {display:none;}
#5 How to hide archives categories in WordPress?
Archives categories refer to URLs automatically generated by WordPress to make redundant content. This sometimes might hurt your SEO. That’s why it’s a better option to disable archives in WordPress.
Although you can hide archives via coding, we recommend installing SEO Ultimate plugin. Trusted by over 100 thousand WordPress users, the plugin effectively hides archives, customizes your homepage’s <title> tag and edits meta description for posts. Here is how to start hiding archives categories on WordPress using SEO Ultimate:
- Install the SEO Ultimate plugin
- Click on Modules under the SEO option
- Scroll down and click Meta Robots Tags option
- Choose Posts to disable the indexing of posts of your domain. Select Defaults tab to disable the indexing according to categories
- Disable the option you want to hide archives from
Above are the most frequently asked questions about hiding WordPress categories. Still have concerns about how to shield categories? Let us know in the comment section below.