Advanced Category Techniques for Filtering Searches and Archives to Members and Non-Members

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.