Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question assumes that you know about the various complex taxonomy queries available from the WP_Query API. I know about tax_query as well as about things like category__and, which allow you to run multi-term queries inside a template.

It also takes for granted the knowledge that you can manually create links, both pretty (/category/mac+mobile/) and ugly (/?cat=2+3) that will generate the results similar to many of the tax_query (or at least category__and) options.

The question is: What is the best way to generate such links within code, so that a theme can automatically link to screens showing complex mixes of categories.

  • The solution should be forward compatible and use standard WP if possible.
  • It should ideally work with any possible permalinks and category-permalink configuration.
  • Ideally it would work with any order of categories, as well as with categories nested inside a hierarchical taxonomy.
  • It should accomodate both intersections (a+b only posts in both categories are returned) and unions (a,b any post in one or the other category works).

As far as I can tell there is no built-in function that can achieve this. The similar function is get_term_link() but it only accepts a single term. Ideally core would have something like get_tax_query_link() that accepted a tax_query and rendered a link that would show the desired results.

share|improve this question

closed as not a real question by Rarst May 27 '13 at 12:32

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Ideally core would have... - this sounds like a trac ticket, not a question. :) What kind of answer are you looking for here precisely? –  Rarst May 12 '13 at 14:24