Archived topic
GP + Marketer Site Title
10 replies · Started by Bill on August 21, 2019
I'm using the Marketer theme from the library. I hooked a static area on the blog page and I have the Title as an H1.
Would you have the code that would let me change the Site Title from an H1 to a p across the entire site?
Thanks
Hi there,
Try this PHP snippet:
add_filter( 'generate_site_title_output', function( $output ) {
return sprintf(
'<%1$s class="main-title" itemprop="headline">
<a href="%2$s" rel="home">
%3$s
</a>
</%1$s>',
'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
Thanks Leo. No luck with that code.
I actually tested that code and it worked for me.
Any chance you can link us to the site in question?
You can edit the original topic and use the private URL field.
Let me know :)
Can you take a look at my site to see if I can change the title tag with the above code?
I believe this post should offer some insight:
https://generatepress.com/forums/topic/site-name-title-tag-search-results/
Got it. Thank you.
No problem :)
Hello!
Any way I could adapt your PHP code to make the site title (what appears next to the logo) an h1 only on the frontpage?
I was thinking of trying this but couldn't find the right template page to add to a child theme:
https://wordpress.stackexchange.com/questions/88144/how-to-have-h1-for-site-title-only-on-homepage
Thank you in advance!
Regards,
Ben
So, I think I found the right file, and based on this I'm not sure why I have a p element for the site title on the frontpage. Maybe I missed some settings?
// Build our site title.
$site_title = apply_filters( 'generate_site_title_output', sprintf(
'<%1$s class="main-title" itemprop="headline">
<a href="%2$s" rel="home">
%3$s
</a>
</%1$s>',
( is_front_page() && is_home() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
) );
Thanks again!
Regards,
Ben
Any chance you can open a new topic for your question?
Thanks :)