0
votes

Basically I have a custom post type of 'products' which has two taxonomies attached to it...the normal 'category' and a custom taxonomy called 'brands'.

I have a page which is 'brand' specific. On this page I'd like to list all the 'categories' that have a 'product' in them with a term of the 'brand' whos page I'm on attached.

Eg. say I'm on the "Nike" page. I want it to list all categories that have a 'product' in them with the 'brand' of "Nike" attached to them.

My initial thoughts are to use get_categories but theres now way to define a specific taxonomy or 'brand'?

$categories = get_categories('orderby=name&depth=1&hide_empty=0&child_of='.$cat);

Anyone done this before or knows a way to query the database directly to get the required results?

Any help is much appreicated, Thanks

3

3 Answers

1
votes

I realize this is an older question, but in case anyone stumbles across this question while looking for an answer (as I did), get_categories() will now do this natively. Note the 'taxonomy' => 'taxonomy-type' in the $args array. Simply provide the registered taxonomy name to override the default value of category.

$args = array(
'type'                     => 'post',
'child_of'                 => 0,
'parent'                   => '',
'orderby'                  => 'name',
'order'                    => 'ASC',
'hide_empty'               => 1,
'hierarchical'             => 1,
'exclude'                  => '',
'include'                  => '',
'number'                   => '',
'taxonomy'                 => 'category',
'pad_counts'               => false );

http://codex.wordpress.org/Function_Reference/get_categories

0
votes

To my knowledge, you cant use the get_categories () function with "Custom Post Types" and "Custom Taxonomies".

On this site you can find a good tutorial in how to use "Custom Taxonomies" http://net.tutsplus.com/tutorials/wordpress/introducing-wordpress-3-custom-taxonomies/.

Under the point "Displaying Taxonomy Classifications on Individual Pages" there would have to the solution for your problem.

0
votes

sorry about the delay. managed to sort it on the Wordpress stack exchange at the following link (for anyone who has the same issue): https://wordpress.stackexchange.com/questions/10998/get-categories-for-custom-post-type-with-a-specific-custom-taxonomy-attached