I'm coding a breadcrumb and I want to return the CPT name in front of the first taxonomy term.
My website's structure is like the following:
- CPT name - Taxonomy Term - Taxonomy Child Term - Post Archive of the articles from the CPT and the two terms
If the user is in the Archive, the Breadcrumb should say:
Home > CPT name > Parent Term > Child Term
I'm currently able to return the parent and child terms, but how do I return the post type name? I have on custom taxonomy for each custom post type, so if would be cool if I could get the post type by a function like this:
global $wp_query; $term_obj = $wp_query->get_queried_object(); $thisTerm = $term_obj->term_id; $thisTerm = get_term( $thisTerm ); $postType = get_category($thisTerm->posttype);
I know that the term object does not have a
posttype-key, but I could get the taxonomy like this. Is there a possibility to get the post type by entering the taxonomy which is registered to it?