Display a specific hierarchical level of a specific custom taxonomy

Change: get_the_category() to get_the_terms( null, ‘taxonomy_name’ ). get_category_link( $cat->cat_ID ) to get_term_link( $cat->term_id ). get_category( $category->category_parent ) to get_term( $category->parent ). If you want to use the same function for multiple taxonomies, you can accept the taxonomy name as an argument and pass it to the first item above: function display_cat_level( $level = 0 , … Read more

Show the section only if custom taxonomy was chosen

You already check, if given post has any terms assigned. All you need to do is to move that check earlier in the code. <?php $terms = get_the_terms( get_the_ID(), ‘colour’ ); if ( $terms && ! is_wp_error( $terms ) ) : ?> <section class=”colour__chart”> <div class=”container”> <div id=”color-chart”> <h2>Colour Chart</h2> <hr class=”divider”> <?php foreach ( … Read more

Getting taxonomies associated with a specified post type

Yes, you can pass a post type to getEntityRecords() and also getTaxonomies(), both using the same format which is an object of arguments: Using getEntityRecords(): wp.data.select( ‘core’ ).getEntityRecords( ‘root’, ‘taxonomy’, { type: ‘post’ } ) Using getTaxonomies(): ( which is actually a shorthand for the above code ) wp.data.select( ‘core’ ).getTaxonomies( { type: ‘post’ } … Read more