26 reputation
4
bio website
location
age
visits member for 1 year, 11 months
seen Aug 15 at 16:13

Jul
25
comment tax_query not working on main query
Thank you for the suggestion and help @G.M.
Jul
25
comment tax_query not working on main query
This solution combines everything in to one query, keeping performance in mind, and uses some nice OOP. Simpler isn't always better.
Jul
25
comment tax_query not working on main query
You run the queries from wp_get_object_terms and then you also run a duplicate query for the main query with get_queried_object just to determine if you should then do the main query. Why not combine all that in to one query, the main query, in a fashion that doesn't slow performance? Milliseconds add up and enough changes to WordPress like this on a single page load in an environment that can't take it and your site will slow to a crawl. This solution just isn't as efficient and is poor practice.
Jul
24
comment tax_query not working on main query
Additionally, Using get_queried_object() will run even more queries on top of that. It's sad to say that in this case I think the simpler solution is not the best solution. (It still however is a solution.)
Jul
24
comment tax_query not working on main query
This simpler solution adds multiple more database queries. It will query each taxonomy referenced (only 1 in this case) and then run a SELECT with multiple JOINs and a WHERE clause. Additionally, there is the possibility of yet another SQL query. Though it may be simpler for all general purposes, my particular code uses an existing OOP class used within my specific code and I cannot afford to run the overhead of these additional queries on a high traffic platform when I can simply modify the original main query.
Jul
23
comment tax_query not working on main query
My particular WordPress instance is a web application that powers around 18,000 website and the individual posts and pages belong to this "site_category" that individual sites "subscribe" to. If the current site is subscribed to category 1 but not category 2, I don't want to show pages that belong to category 2 for that particular site and they need to return 404. It's basically a different low-overhead version of doing a WordPress MultiSite.