Archived topic
Is there a way to replace the site tile with the curent post title in the header
1 reply · Started by Leonard on February 22, 2023
I just bought into GP Premium and am building my first site with it.
I was wondering if it is possible to have the post title displayed in the header. And so replacing the site title.
Using the customizer, I couldn't find a way to do this.
I am on the latest version of the Theme and Plugin.
Hi Leonard,
I don't think it's a good idea, as then you will have many site titles, it's not great for SEO, and might get the bot confused.
But if you insist, you can try this PHP snippet:
add_filter( 'generate_site_title_output', function( $output ) {
return sprintf(
'<%1$s class="main-title" itemprop="headline">
%3$s
</%1$s>',
( is_front_page() && is_home() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_the_title()
);
});