I tested it, and by default it will show it to everyone even if one of the categories is member only. If you need a fix for that(like me), then use the following in functions.php
:
function my_filter( $content ) {
$categories = array(
'news',
'opinions',
'sports',
'other',
);
if ( in_category( $categories ) ) {
if ( is_logged_in() ) {
return $content;
} else {
$content="<p>Sorry, this post is only available to members</p>";
return $content;
}
} else {
return $content;
}
}
add_filter( 'the_content', 'my_filter' );
from my other question.
Related Posts:
- Only one category per post
- How to get permalinks with category base working with sub-categories
- WP 3.9 TinyMCE no longer loads on category description editor
- get_categories hierarchical order like wp_list_categories – with name, slug & link to edit cat
- Change Gutenberg category checkboxes to radios
- Exclude categories from search query
- Why is per_page not working with categories in WP API?
- Programmatically create product category and add thumbnail in woocommerce
- How to order the get_categories result
- List posts by category exclude current post
- How can I calculate the total number of categories at different hierarchy levels?
- In the tag archive – display count of posts for each category they belong to
- How to add a background image to category and display image on category page
- Display only deepest category on a single post?
- How we add new categories by wp_insert_post
- Listing all posts from current category on page
- Show Subcategory Description
- Hide uncategorized products from the shop page
- I want exclude the particular category in sidebar
- get only sub category ID
- Display categories inline
- Add a specific category at a specific place to the menu that uses wp_list_pages
- Categories not working – 404 Not found error
- How to not treat categories as tags in feeds
- How would I go about pulling the most popular (most used) categories?
- New Theme creation
- Custom order categories in admin dashboard
- multiple categories and breadcrumbs problem
- Group listed elements by category
- Editing Category Pages
- List subcategories of a specific product category (adapting from posts to products taxonomy)
- Display tags from specific category in select fields
- woocommerce product category tabs [closed]
- Taxonomy name repeating when showing 2 posts from each category
- How to change category and year archive permalinks/rewrite rules?
- The Category page shows all the posts, without differentiating by categories
- Category param redirect to post type archive
- batch adding posts to a category based on matching regex for title with SQL
- Display Posts Loop for each parent and for each Child
- Removing subcategories from permalinks [duplicate]
- Different banner for different section
- Flat category URLs but retaining hierarchy?
- Creating a custom feed for categories that includes the first post’s featured image
- How to query categories with Advanced Custom Fields?
- echo category description in single.php
- Link to the next/prev posts in index loop in same category?
- How to automatically check multiple categories on new post
- How do I get the parent category if I know the child category?
- get_the_categories() but exclude children of “Uncategorized”
- How to exclude a particular category from the category list
- Hide specific category from wp_list_categories
- ow to display the number of posts in a category
- Force category choice before creating new post
- How to modify the “View all posts in category” title attribute
- Show post categories
- Exclude categories by ID
- Add description to categories menu in admin
- Display Sub-categories or Child Pages of Parent Cat/Page?
- How to check if a categoryID exists in a theme options page
- How to display product categories and number of sales on WooCommerce
- Display one category and its suncategories
- How to differentiate the homepage structure from the category page structure in WordPress template?
- Global navigation in multisite: problem with categories
- Placing category specific banner/html at top of respective category pages
- How to remove category name for only one category?
- Get parent category field from child category [closed]
- Custom sidebar isn’t showing up on sub-category posts
- Taxonomy custom check box meta field not getting saved
- Subcategories randomly not working after page/post/category edit in wordpress. Fix: saving permalinks twice
- Can a Woocommerce product category URL contain “&”?
- How can I display all products from all categories on one page with woocommerce?
- Unable to create pagination for Category.php
- Function add class to second menu specific items if the page has a certain category
- Posts says they are uncategorized but they are not
- How to call Primary Category for WordPress Woocommerce
- Meta Box: display single image on an archive-template
- I just want to list ONLY the child categories, but not grandchildren
- Search Replace Database ONLY for posts of certain category?
- Categories Help and video uploads
- Display only children of custom hierachial taxonomy
- Read More showing only on first post
- Filtered post assigned to categories
- Paginations in Category Page Leads to Sample Pages
- Allow a user to ‘subscribe’ to different post categories?
- Most efficient way to have 1 template for parent, 1 template for child categories?
- If on Category Page add “active” class?
- Transfering static site to wordpress and retaining category by month paginations
- Make three menus with three category levels
- Show only one category in main query, issues on tag page
- Bringing Ajax Loading Feature on Category Pages
- How to have a category not show up in query post with page panigation?
- single category widget with conditional terms
- Remove the current item from a menu
- Show category-ID in custom category-list
- Dynamically Adding Category Specific Content To Specific Category & Subcategory Pages
- Structure with category setting
- Do not show all post from all categories, just show posts from category in current loop
- How to prevent page re-sizing for mobile browsers [closed]
- How to display all category images for single post in a page?
- How to add custom prefix before category base for category page URL?