Skip to content

Instantly share code, notes, and snippets.

@brasofilo
Created October 1, 2013 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brasofilo/6783653 to your computer and use it in GitHub Desktop.
Save brasofilo/6783653 to your computer and use it in GitHub Desktop.
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