Hello,
I have the below function which I assign as an add_action to woocommerce_shop_loop_subcategory_title
For my WooCommerce categories I have an ACF Post Object field for assigning an icon. For now I’m just trying to grab the category object so that I can hook it to my ACF get_field request. I’ve tried get_queried_object()
but this returns the page that the categories are listed on, and I’ve tried global $category but this doesn’t seem to work either.
function is_before_sub_category_title(){
$the_category = get_queried_object();
$cat_id = 'product_cat_'.$the_category->term_id;
$category_icon = get_field('icon', $cat_id);
}
add_action( 'woocommerce_shop_loop_subcategory_title', 'is_before_sub_category_title', 5 );
Any ideas please?