Skip to content

Instantly share code, notes, and snippets.



Last active Apr 23, 2019
What would you like to do?
Link Genesis post title directly to content when using the Link post format
add_filter( 'genesis_post_title_output', 'sp_link_post_format_title' );
* If the post uses the “Link” post format and has a URL in the content,
* link the title directly to that URL instead of to the post itself.
* @param string $title_html The original title HTML.
* @return string The updated HTML.
function sp_link_post_format_title( $title_html ) {
if ( get_post_format() !== 'link' ) {
return $title_html;
$url_in_content = get_url_in_content( get_the_content() );
if ( $url_in_content ) {
return preg_replace('/<a(.*)href="([^"]*)"(.*)>/','<a$1href="' . $url_in_content . '"$3>', $title_html );
return $title_html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.