How Do I Find the Current Post Taxonomy in WordPress?

When you want to find the post taxonomy in WordPress, you can use the following code:

function get_post_taxonomy_by_slug() {
$query = new WP_Query();
$query->set(‘slug’, $query->get(‘slug’));
$posts = $query->get_posts();
$taxonomy = $posts->get_taxonomy();
return $taxonomy;
}

The get_post_taxonomy_by_slug function will return the post taxonomy for the given slug.