Skip to content

Instantly share code, notes, and snippets.

@nickcernis

nickcernis/functions.php

Last active May 12, 2020
Embed
What would you like to do?
Wrap Genesis titles with a link on singular posts and pages
<?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
You can’t perform that action at this time.