Archived topic
Links in Widget Titles
1 reply · Started by Eran on August 25, 2018
Viewing posts 1–2 of 2
Hey GP dudes
I was wondering, is there a way to make the titles of my widgets clickable? For example, I have an Instagram widget on http://www.zetaim.com and I want the title of that to link to my account.
I'd love to do so without plugins. Is it possible?
Thanks!
Hi there,
You could try adding a function like this:
add_filter( 'widget_title', function( $mytitle ) {
$mytitle = str_replace( '[link', '<a', $mytitle );
$mytitle = str_replace( '[/link]', '</a>', $mytitle );
$mytitle = str_replace( ']', '>', $mytitle );
return $mytitle;
} );
Then you can do something like this in your widget title:
[link href = http://google.com]My Widget Title[/link]
Hope this helps :)
This archived topic is closed to new replies.