I have the following function which I need to apply on a particular category only:
function ChangeSelectTitle($woocommerce_product_categories_widget_args){
$woocommerce_product_categories_widget_args['show_option_none'] = __('Select your Device/Brand');
return $woocommerce_product_categories_widget_args;
}
if( $product_cat_id == 6 ) {
add_filter('woocommerce_product_categories_widget_dropdown_args', 'ChangeSelectTitle');
}
The category ID is 6. I have tried putting $product_cat_id == 6
to identify the category page but it's not working. How to make it work?
$product_cat_id
from?global $product_cat_id;
before you could use it. Anyway, I suspect you're barking up the wrong tree. The widget args are set before it builds the category list, so you can't hope to effect it like that. Also, the text you're looking to change is displayed when there are no categories to display. The original text is "No product categories exist", so changing it to "Select your Device/Brand" doesn't make sense to me as there's nothing to select!