Is there any way to filter all post queries and add a specific taxonomy? Case in point, I have a taxonomy object of “Region” with terms like “Global”, “Americas”, “Europe”, etc. (Users designate their region in their user profile through custom fields which is stored as a usermeta value and added the user cache object.)
The idea being that as the signed-in user navigates the site, they’d only see content designated within their region. Obviously I could write a custom query per page to include their region, but I was wondering if there was a way to tap into the query object and add the taxonomy requirement regardless of what the query was for (e.g, post, custom post type, archive page, etc.).
Any help would be much appreciated! Thanks.
Below code is an example that does what you want. See tax_query for more information.