$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Change The Woocommerce Product Categories Dropdown Widget Placeholder Text|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Change The Woocommerce Product Categories Dropdown Widget Placeholder Text

matteradmin8PV0评论

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/

Post a comment

comment list (0)

  1. No comments so far