[wp-hackers] get_terms & post_type

Braydon ronin at braydon.com
Tue Jul 26 11:01:40 UTC 2011


On 07/16/2011 03:42 PM, Braydon Fuller wrote:
> I've setup a site that uses shared post_terms across all post_types 
> and need to be able to get the terms that are specific to one post 
> type. I've looked at the documentation of get_terms and didn't find 
> anything available, I've read the source for get_terms and didn't find 
> any actions or filters to be able to work with the where clause.
>
> I have found this article on the net with a way to do it 
> (http://wordpress.stackexchange.com/questions/14331/get-terms-by-taxonomy), 
> but it seems overly complex, when all that is needed is an additional 
> SQL WHERE in get_terms.
>
> Does anyone know of other ways to do this without modifying the core, 
> or is that the best way to go about this?
>
> I've also submitted a ticket for a feature request #18106 on the trac 
> (http://core.trac.wordpress.org/ticket/18106)

After looking more into this the get_terms function would need to be 
modified greatly to support this, since it requires joining two other 
tables, that I didn't realize on my first read of the source. Here is 
the SQL if anyone is interested, it's limited in parameters, but it does 
the job.
http://core.trac.wordpress.org/ticket/18106#comment:1


More information about the wp-hackers mailing list