Change The Woocommerce Product Categories Dropdown Widget Placeholder Text

admin2025-06-02  1

I've searched everywhere on the internet and tried to code it myself I want to change the default "Select A Category" placeholder text to "Select A Sub Category" so far I have tried this but it's not working:

function _category_dropdown_filter( $list_args ) { $list_args['show_option_none'] = __('Select A Sub Category'); return $list_args; } add_filter( 'woocommerce_product_categories_widget_arg' , '_category_dropdown_filter' );

Also, I have even tried to edit this file here but I see no "Select A Category" woocommerce/includes/widgets/class-wc-widget-product-categories.php

I've searched everywhere on the internet and tried to code it myself I want to change the default "Select A Category" placeholder text to "Select A Sub Category" so far I have tried this but it's not working:

function _category_dropdown_filter( $list_args ) { $list_args['show_option_none'] = __('Select A Sub Category'); return $list_args; } add_filter( 'woocommerce_product_categories_widget_arg' , '_category_dropdown_filter' );

Also, I have even tried to edit this file here but I see no "Select A Category" woocommerce/includes/widgets/class-wc-widget-product-categories.php

Share Improve this question asked Sep 24, 2018 at 13:54 Nexus TeesNexus Tees 11 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 2

This worked for me:

add_filter( 'wp_dropdown_cats', function( $html, $args ) {
    if ( $args['taxonomy'] === 'product_cat' ) {
        $html = str_replace( '<select', '<select data-placeholder="New Placeholder"', $html );
    }
    return $html;
}, 10, 2);

Try to using apply_filters in your functions.php

apply_filters( 'woocommerce_product_categories_widget_args','art_architecture_textbooks' );
function art_architecture_textbooks( $cat_args ) {
        $cat_args['show_option_none'] = __('Art & Architecture');
        return $cat_args;
}

Learn more https://siteorigin/thread/change-category-widget-default-text-select-a-category/

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748848595a314228.html

最新回复(0)