When creating and editing your site’s Membership Levels, you can choose to add membership requirements at the post category level. By doing this, any post in that category will automatically have the access restrictions in place. This recipe demonstrates how to remove that access restriction on specific post IDs, regardless of the category’s settings….
If you’ve set the option “Filter Searches and Archives” to “Yes” under the Memberships > Advanced Settings page, all of the posts in your members-only categories will be hidden from the main page, archives, and search queries. This code gist allows you to add specified categories back into the query.