1
votes

I have 2 custom taxonomies.
Each of them are related with few post types to be used with.
For example, taxonomy 'topic' is related with custom post type 'product'.
taxonomy 'source' is related with custom post type 'product' and 'program'.
Now I want to get the all taxonomies related to custom post type 'product'.
Following is what I tried to do.

 $args=array(
       'object_type' => array('product') 
 );
 $output = 'objects';
 $taxonomies= get_taxonomies($args, $output);

The problem is that the get_taxonomies() function returns 'topic' taxonomy only.
But I want to get all of 2 taxonomies: 'topic' and 'source'.
Any advice?

1

1 Answers

0
votes

You can try get_object_taxonomies

I have no environment right now so this code is not tested. Just give it a try and let me know:

$taxonomy_objects = get_object_taxonomies( 'product', 'objects' );
print_r( $taxonomy_objects); // debug

More info in Wordpress Codex