On my site, each post is linked to a required custom field 'language' and a required custom field 'theme' (which values end up stored as postmeta) Language and theme values are chosen within a GIVEN set.
Now I want users to be able to tag each post, BUT each tag term should only be associated with a 'language' AND a 'theme'.
So that a term in the site's context would always be bound to a language/theme pair. For instance, let's say I create a post 'Francois Hollande elu president de la republique' (Hollande elected president of the french republic) to which I associate language 'French' and theme 'Politics'.
Then the available terms for tagging would be restricted to tags linked to posts written in 'French' with 'Politics' as a theme, say : 'france', 'elections presidentielles 2012', 'parti socialiste'.
Similarly, if I create the term 'crise economique' (economic breakdown) along with this post (the way it works in the backoffice of WordPress), then this term would only be made available to posts that have language 'French' and theme 'Politics' as attributes.
Basically, my problem is that I can't think of a proper way to build the SELECT sql query using the most of (or even some of) WordPress, which general idea would be :
"select all terms that are linked with posts that have a postmeta key 'language' set to <selected_language> and a postmeta key 'theme' set to <selected_theme>"
Here's what I found out :
the native WP functions get_terms and such don't seem to be customizable the way I'd need them to be.
there doesn't seem to be the equivalent of WP_Query class (used for posts/pages) for terms
Is there a way through this that minimizes non WordPress PHP coding ?
Should I hard code full SQL requests ?
Should I create a table to bind terms and language/theme post attributes ?
What about requests cost, especially if there is a way to go without any custom table ?
Hope I have made myself clear about the problem. Any insight will be much appreciated. Thanks in advance :)