[wp-hackers] Get non empty taxonomy terms, restricted by post type.

Cornelius, Gregory gcorne at bu.edu
Thu Jan 19 21:01:22 UTC 2012


The count stored in wp_term_taxonomy is not post_type specific, so
get_terms() cannot support what you are after given the current WordPress
schema.

On 1/19/12 10:16 AM, "Tom Barrett" <tcbarrett at gmail.com> wrote:

>I have a noddy solution:  loop through all the terms checking each one to
>see if contains posts with the right post type, adding any to an exclude
>array that do not. I expect it can have some performance issues reasonably
>quickly.
>
>http://pastebin.com/MDPGaRAz
>
>
>
>On 19 January 2012 12:52, Tom Barrett <tcbarrett at gmail.com> wrote:
>
>> If I have a taxonomy spanning multiple post types (specifically, I have
>> added core categories to a 'books' product type), how do I find all the
>>non
>> empty category terms for 'books'. I.e. exclude category terms that are
>>used
>> posts, pages e.t.c.?
>>
>> I can't see any arguments or filter hooks where I can change the
>>behaviour
>> of wp_dropdown_categories() or get_terms().
>>
>> --
>> http://www.tcbarrett.com | http://gplus.to/tcbarrett |
>> http://twitter.com/tcbarrett
>>
>
>
>
>-- 
>http://www.tcbarrett.com | http://gplus.to/tcbarrett |
>http://twitter.com/tcbarrett
>_______________________________________________
>wp-hackers mailing list
>wp-hackers at lists.automattic.com
>http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list