Last active
May 12, 2020 12:47
-
-
Save nickcernis/3ef8d7c73c7d75107af2cc1dc8350e5b to your computer and use it in GitHub Desktop.
Wrap Genesis titles with a link on singular posts and pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'genesis_post_title_output', 'custom_wrap_singular_titles_with_links', 10, 3 ); | |
/** | |
* Wrap the post title with a link on singular entries. | |
* | |
* @param string $output The original title output (title content and tags). | |
* @param string $wrap The title tag. | |
* @param string $title The content of the title tag. | |
* @return string The new title output. | |
*/ | |
function custom_wrap_singular_titles_with_links( $output, $wrap, $title ) { | |
if ( ! is_singular() ) { | |
return $output; | |
} | |
$title = genesis_markup( | |
[ | |
'open' => '<a %s>', | |
'close' => '</a>', | |
'content' => $title, | |
'context' => 'entry-title-link', | |
'echo' => false, | |
] | |
); | |
$output = genesis_markup( | |
[ | |
'open' => "<{$wrap} %s>", | |
'close' => "</{$wrap}>", | |
'content' => $title, | |
'context' => 'entry-title', | |
'params' => [ | |
'wrap' => $wrap, | |
], | |
'echo' => false, | |
] | |
); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment