• This is in the hardcode of a plugin for a widget title (woocommerce plugin):

    $title = apply_filters(‘widget_title’, empty( $instance[‘title’] ) ? __( ‘Product Categories’, ‘woocommerce’ ) : $instance[‘title’], $instance, $this->id_base);

    I would prefer not to use a title for a widget but unfortunately there is no option and if you leave the title blank then a default ‘Product Categories’ is used, as shown in the code above.

    Can you let me know a filter function to remove this default value, so I am able to have no title for this widget?

    I’ve tried the following with no luck because the variables (such as $this) isn’t passed. I think I’m on the right track though:

    function custom_widget_title() {
    $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);return $title;
    }
    add_filter('widget_title', 'custom_widget_title');

    Many thanks,
    Steven

Viewing 1 replies (of 1 total)
  • Thread Starter scdwb

    (@scdwb)

    Hmm, actually this seems to have done the trick:

    function custom_widget_title($title) {
    $title = $title;
    return $title;
    }
    add_filter('widget_title', 'custom_widget_title');

    Not entirely sure how, but it’s working how I need it to. When I leave widgets titles blank they no longer appear with any default titles (just what I need) and when I fill in a widget title they appear.

    Great ??

    Steven

Viewing 1 replies (of 1 total)
  • The topic ‘widget_title filter to remove default value’ is closed to new replies.