Activate “Content View Access Restrictions” module at User Role Editor Settings page:
Post level restrictions
If you wish to restrict the post view by users with the selected roles only follow these steps:
1) Open the post for edit, scroll to “Content View Restrictions” metabox.
2) Select a kind of restriction, for whom apply it and what to do in case of access error:
3) Click “Edit Roles List” button and select role(s) for which you wish to apply access restriction action. Click “Save” button, check that roles list at the readonly textarea was updated.
Do not forget to click “Update” button to save full changes made to the post including roles list you just built.
Done. This post is available for logged-in users with selected roles only. If you selected action “Prohibit”, that this post is available for the all roles except included into the roles list.
Category level restricitons
If you wish to restrict the view of a group of posts at once you may set view restrictions for selected category. Open needed category for editing. You will see the same “Content View Restrictions” section as shown for post above.
All posts of this category will have restricted view according to the settings you made here.
Role level restrictions
It’s possible to set content (posts/pages/custom posts types) view restrictions on a role level:
Go to “Users->Users Role Editor”. Select role and click “Posts View” button:
At opened dialog select/input appropriate access restrictions options:
In some cases it will be needed to allow authors to see just their own posts at front-end. You can achieve that with this settings:
a) Block – Not Selected
b) Own data only – turned ON.
The example of using this feature with WooCommerce products and categories:
Restrict WooCommerce products view by category
If you are interested how to add content view restrictions for post programmatically read this article.