Create a gist now

Instantly share code, notes, and snippets.

Using URLs in Widget Titles. Using the format TITLE||URL||TARGET, being target optional. Nice article with many methods: http://www.rvamedia.com/wordpress/customize-wordpress-widget-title
<?php
add_filter( 'widget_title', function( $title )
{
$pieces = explode( '||', $title );
if( isset( $pieces[1] ) )
{
$target = isset( $pieces[2] ) ? "target='{$pieces[2]}'" : '';
$new_title = sprintf(
"<a href='%s' %s>%s</a>",
$pieces[1],
$target,
$pieces[0]
);
}
$return = isset( $new_title ) ? $new_title : $title;
return $return;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment