Archived topic
Can I make the site description (tag line) into a link?
3 replies · Started by Sue on October 25, 2021
I found instructions on how to change the URL of the site-title by adding a code snippet:
add_filter( 'generate_site_title_href','generate_custom_site_title_href' );
function generate_custom_site_title_href()
{
// Enter the URL you want your logo to link to below
return 'http://YOURURLHERE.com';
}
Is it possible to tweak this code snippet to make the site description (tag line) clickable? I tried changing "title" to "description" but it didn't seem to work.
Hi Sue,
That filter is for the site title href. There's no generate_site_description_href filter so changing "title" to "description" won't work.
If you want to filter the site description specifically, you can use generate_site_description_output.
https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/header.php#L217-L226
You'll have to do something like this:
add_filter('generate_site_description_output', function($output){
$output = sprintf(
'<p class="site-description"%2$s>
<a href="%3$s" rel="home">
%1$s
</a>
</p>',
html_entity_decode( get_bloginfo( 'description', 'display' ) ), // phpcs:ignore
'microdata' === generate_get_schema_type() ? ' itemprop="description"' : '',
esc_url( home_url( '/' ) )
);
return $output;
},10,1);
Perfect, thanks! That's exactly what I wanted.
Nice one. No problem. :D