How should I intercept the main query and inject custom join / order by / group by criteria

If I understood you right…

  • [A] Multi-Tax queries have the problem that they’re doing a JOIN of the meta table for every term. So imho it’s not the best idea to use the built in way.
  • [B.1.a] I’d simply do a normal query with a one (main-)tax arg and then do the sorting depending on the meta values. So actually just calling get_post_custom() and merging it with a single post object during a loop and then appending it to a resulting array.
  • [B.1.b] Then modifying the query through posts_clauses if some bits doesn’t meet the requirements.
  • [B.2] Start sorting for e.g. by name.
  • [B.3] Then I’d go and run some foreach/etc loop on the resulting array.

The benefit of browser/php vs. DB isn’t there so far (as long as the site hasn’t got much hits). But if you start minifying css/js/html and caching the resulting stuff (and delivering the results from the hard disk), I think this would be the way I’d go.

Leave a Comment