Creating protected WordPress categories
The Password Protected Categories plugin provides a simple and effective way to protect categories for any type of content on your website, such as pages, posts or other post types. This article will explain how to create password protected categories; and how to restrict categories so that only specific roles or individual users can access them.
Password protected, user and role protected categories
Follow these steps to protect any type of category or taxonomy in WordPress. You can protect as many categories as you like, while leaving others public:
- To create password protected categories for any type of WordPress content, go to the Categories screen for the relevant post type (e.g. Posts → Categories). Click the option to either add a new category or edit an existing one.
- Tick one or more of the following category protection options:
- Password protected - Password protect the category by adding one or more passwords. To add more passwords for a category, click the plus (+) icon next to the password box and add a new row for each additional password. Click the minus (-) icon to delete a password. Customers can unlock the category by entering any correct password.
- User roles - Click in the box and select one or more user roles who will have access to the protected category.
- Users - Click in the box and select one or more specific users who will have access to the protected category. (Tip: If you have lots of users, start typing a username in the box to search for a specific user.)
You can protect as many of your WordPress post or custom post categories as you like, and leave others public.
- For more information about how protected categories work together and the logic rules in the plugin, please see this article.
- To learn how to redirect users to their protected category page after they login, please see this article.
The plugin also has an option to mark categories as 'Private'. This automatically shows the category and its contents to logged in users with certain user roles, while hiding it from everyone else.
Private categories work in exactly the same way as private WordPress pages or posts, which you can read about in the WordPress Codex. They are normally restricted to Administrators and Store Managers.
For most people, we recommend using the 'User roles' option rather than 'Private'. This is because the 'User roles' option gives you more control over which user levels can access the category. Please see our separate article if you do wish to create private categories.
How to protect sub-categories
You can create more complex navigation structures by protecting a category and adding ‘child’ categories to it. To add sub-categories, create a new category and select your protected category as the ‘Parent’. You can also create deeper navigation levels by creating sub-sub-categories, sub-sub-sub categories, and so on.
All sub-categories should be set to 'Public'. The protection for the main ‘parent’ category will automatically apply to all its child categories so you don’t need to protect each one individually.
For example, let's say that you password protected a category and added various child and grandchild categories. When someone tries to view the main parent category, a child category, a grandchild category or any of the items within these categories, they will be promoted for the same password. Once they have entered the password, they will automatically have access to all these categories and their contents.
Can I add a post to more than one category?
Each post, page or custom post can only be in one protected category, otherwise it creates a conflict between the different protection methods. Similarly, you can't have the same post in a public AND a protected category, as it will automatically be protected if you do this.
We recommend that you structure your site with this in mind. For example:
- If you want to show the same protected post to different user groups, then you will need to duplicate them and put one in each category. (The Duplicate Post plugin makes it easy to duplicate posts and other post types.)
- If you need to add the same product to multiple categories that are available to the same users, then it's ok to add it to more than one category. Just make sure you protect each category in the same way. For example, if you're adding the product to more than one password protected category, then you will need to add the same password for each category. If you're using role or user protection, then each category will need to be restricted to the same roles or users. This will prevent any conflicts.
Will my protected categories be hidden from search engines?
Please note that Password Protected Categories does not affect how search engines view your categories or products.
There are some steps you can take to hide your protected content from search engines:
- Use an SEO plugin such as Yoast SEO to mark the categories and products as ‘noindex’. This will prevent them from being indexed at all.
- If your Catalogue Visibility settings are set to hide your protected categories and products from the public areas of your store, then search engines are unlikely to crawl them because this only happens if a search engine can find them. However, there may still be links to your protected categories and products elsewhere, such as your XML sitemap, so it’s worth noindexing them if you are concerned about this.
How to password protect an entire blog, portfolio or other content type
You can use the WordPress password protect plugin to password protect your whole blog section or an entire custom post type.
- Create a main category for your posts or custom post type and password protect it (see above). You can then structure all the content within the post type by adding sub-categories. Add all the posts to the main category and/or its sub-categories. You should leave the individual sub-categories set to ‘Public’ as they will automatically be protected with the same password as the main parent category.
- Go to Settings → Protected Categories and make sure the ‘Show password protected categories and posts to visitors’ box is not ticked.
How to create a category login page
There are several ways for people to log into your protected categories. Please see our article on category login pages.
How to password protect WooCommerce categories
You can use the Password Protected Categories plugin to password protect WooCommerce categories. However if you’re using it for WooCommerce then you might prefer our other plugin, WooCommerce Password Protected Categories.