get the custom taxonomy name?

In function.php I have this hook :

add_action( ‘woocommerce_before_single_product’, ‘display_category_list’,20 );

function display_category_list() {
wc_get_template( ‘woocommerce/single-product/single-product-top-
content.php’ );


But I need to activate this hook ONLY on products pages that belongs to a certain custom taxonomy.

so I need to find out in each product what is the custom taxonomy.
now I have this code :

$taxonomy_objects = get_object_taxonomies( ‘product’, ‘objects’ );
print_r( $taxonomy_objects);

this is what I get :

Array ( [product_category] => WP_Taxonomy Object ( [name] =>
product_category [label] => Product Categories [labels] => stdClass Object
( [name] => Product Categories [singular_name] => Product Category
[search_items] => Search Product Categories [popular_items] => [all_items]
=> All Product Categories [parent_item] => Parent Product Category
[parent_item_colon] => Parent Product Category: [edit_item] => Edit Product

this is what I need

how do I do this?

Read more here:: get the custom taxonomy name?

Leave a Reply

Your email address will not be published. Required fields are marked *