ThisCalculator

Everyday

Limit Access Categories WordPress: How to Restrict

Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered

Limit Access Categories WordPress: How to Restrict

To limit access to categories in WordPress, you need to control which user roles or individual users can view or edit posts within specific categories. This is not a built-in feature, so you must use a plugin, custom code, or a membership solution to restrict category access. Below we explain the main methods, their trade-offs, and how to choose the right one for your site.

Formula

The calculator above computes your average pace and speed for a given distance and finish time. The formulas are:

  • Pace = Finish time (minutes) ÷ Distance (km) → result in min/km
  • Speed = Distance (km) ÷ (Finish time (minutes) ÷ 60) → result in km/h

Where:

  • Finish time (t) is the total time in minutes.
  • Distance (d) is the distance in kilometers.

If you use miles, convert distance to km (1 mile = 1.60934 km) before entering, or convert the result accordingly.

Worked Example

Using the default values (finish time = 50 minutes, distance = 10 km):

  1. Pace = 50 ÷ 10 = 5.00 min/km
  2. Speed = 10 ÷ (50 ÷ 60) = 10 ÷ 0.8333 = 12.00 km/h

The calculator shows an average pace of 5.00 min/km and an average speed of 12.00 km/h.

Why Limit Category Access?

Limiting category access is a common need for sites that have multiple authors or paid memberships. For example, you might want only editors to see draft posts in a “Pending Review� category, or you might want premium subscribers to access a “Members Only� category while free users see nothing. Without restriction, anyone with the appropriate role can see all posts in all categories, which can lead to content leaks or unauthorized edits.

Built-in WordPress Capabilities

WordPress has a built-in role system (Administrator, Editor, Author, Contributor, Subscriber) and each role has capabilities like edit_posts or read. However, these capabilities are global—they apply to all posts, not per category. There is no native way to say “this role can edit only posts in the News category.� To achieve category-specific restrictions, you need to extend the system.

Method 1: Using a Plugin

The easiest way for most site owners is to install a plugin that adds category-level permissions. Popular options include:

  • User Role Editor – Allows you to create custom roles and assign capabilities per category (with the Pro version).
  • Capability Manager Enhanced – Similar to User Role Editor, offers category-based restrictions in the paid version.
  • Members – A free plugin that lets you restrict content by role, but category-specific access requires the paid add-on.
  • Paid Membership Pro – If your goal is to restrict categories to paying members, this plugin integrates category access with membership levels.

With most of these plugins, you go to the plugin’s settings, select a category, and choose which roles can view or edit posts in that category. The plugin then modifies the WordPress query and permission checks to enforce the rule.

Method 2: Custom Code (Functions.php)

If you prefer not to use a plugin, you can add custom code to your theme’s functions.php file (or a site-specific plugin). The most common approach is to filter the main query to hide posts from restricted categories, and to check user capabilities before allowing edit access.

Example for hiding posts from a category for logged-out users:

function restrict_category_for_logged_out($query) {
    if ( !is_admin() && $query->is_main_query() ) {
        if ( !is_user_logged_in() ) {
            $query->set('cat', '-5'); // Exclude category ID 5
        }
    }
}
add_action('pre_get_posts', 'restrict_category_for_logged_out');

For edit access, you would need to hook into map_meta_cap or user_has_cap to deny editing for specific categories. This is more complex and requires careful testing. Always back up your site before editing code.

Method 3: Membership and Content Restriction Plugins

If your goal is to restrict entire categories to paying members, a dedicated membership plugin is often the cleanest solution. Plugins like Restrict Content, Paid Membership Pro, or MemberPress (paid) allow you to assign categories to membership levels. Visitors without the required level see a teaser or a login prompt instead of the full content. This is different from role-based editing restrictions—it focuses on viewing access, not editing.

Common Mistakes and Pitfalls

  • Forgetting about RSS feeds – Category restrictions often don’t apply to RSS feeds, so content can leak. Check your feed settings or use a plugin that also restricts feeds.
  • Ignoring direct URLs – Hiding a post from the category listing does not prevent someone from accessing the post directly via its URL. You must also restrict the single post page.
  • Not testing with different roles – Always test with a non-admin user to ensure the restriction works as intended. Administrators often bypass all restrictions, which is normal.
  • Confusing view and edit permissions – Some plugins only restrict editing, not viewing. Make sure you know which one you need.

Choosing the Right Method

Consider your technical comfort and budget:

  • If you want a quick, no-code solution, use a plugin. Free versions may cover basic view restrictions, but editing restrictions often require a paid upgrade.
  • If you only need to hide categories from logged-out users, a simple code snippet or a free plugin like “Restrict Categoriesâ€� may suffice.
  • If you run a membership site, invest in a membership plugin that handles category access, payment, and content dripping.
  • If you are comfortable with PHP, custom code gives you full control but requires maintenance when WordPress updates.

Frequently Asked Questions

Can I restrict categories without a plugin?

Yes, you can add custom code to your theme’s functions.php file. The code can filter the main query to hide posts from certain categories for specific users. However, it requires some PHP knowledge and testing. For most users, a plugin is simpler and more reliable.

Will category restrictions affect my site’s SEO?

If you hide posts from search engines using noindex or robots.txt, it can affect SEO. But if you only restrict access for logged-out users while still allowing search engines to crawl (which is possible with some plugins), your SEO may remain unaffected. Be aware that search engines might index content that is behind a login if they can access it, so use proper noindex for restricted content if you don’t want it indexed.

Do category restrictions apply to RSS feeds?

Not automatically. Many plugins that restrict category access also have an option to restrict feeds, but it’s not always enabled by default. Check your plugin settings or add a custom filter to exclude restricted categories from feeds.

Can I restrict categories for specific users, not just roles?

Yes, some plugins allow per-user overrides. For example, User Role Editor Pro lets you assign category permissions to individual users. In custom code, you can check the user ID in the filter function.

What happens to existing posts when I change category restrictions?

Existing posts remain in their categories, but they become hidden or inaccessible to users who don’t have permission. If you remove a restriction, all posts in that category become visible again. No posts are deleted.

Is it possible to restrict categories for the frontend but not the admin?

Yes, most plugins and custom code can distinguish between frontend and admin. You can hide categories from the frontend while still allowing admins to see and edit them in the dashboard. This is common for draft or internal categories.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.