Replace the title of widget
-
I want to replace the title of a widget anytime my widget title text starts with ‘(new)’.
I tried the following in functions.php:
add_filter('widget_title', 'my_filter_widget_title', 10, 3); function my_filter_widget_title($title, $instance, $wid){ if(substr($title, 0, 5) == '(new)'){ return $title = str_replace('(new)', "(old)", $title); } }
but this thing completely removed my sidebar (it wasn’t visible anymore).
Is it possible to do what I want to do? What’s the right way to do it?
Thanks in advance
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Replace the title of widget’ is closed to new replies.