How can i get taxonomies of a post type?
If I have a post type event
and i need to find out the list of taxonomies that are attached to that post type. How do I find them?
How can i get taxonomies of a post type?
If I have a post type event
and i need to find out the list of taxonomies that are attached to that post type. How do I find them?
You must be logged in to post a comment.
I think I’ve got it! After looking at couple of functions in the taxonomy.php file in WordPress I have found the function
get_object_taxonomies();
which did the trick 🙂get_categories will do the job.
Apologies for raising an old post, but I came across this problem while looking for an answer for my use case.
I wanted to retrieve all available taxonomies for a post type, and also retrieve all available terms per taxonomy.
Thank you to Nick B for setting me in the right direction with his answer: https://wordpress.stackexchange.com/a/357448/198353
Have you tried anything? something like this?
Use
get_object_taxonomies
(https://developer.wordpress.org/reference/functions/get_object_taxonomies/), which takes either the name of your custom post type or a post object as the parameter:get_taxonomies()
won’t return any taxonomies that are used by multiple post types (https://core.trac.wordpress.org/ticket/27918).https://developer.wordpress.org/reference/functions/get_post_taxonomies/
This worked for me.