Archived topic
Wrong title showing as h1 tag
46 replies · Started by Joe on May 22, 2020
Followed the video instructions to activate the Disable Elements and Elements. Gone into pages but the field with the options are not in here as in video.
Strange why I'm not seeing this. Just went through looking for this again.
It should definitely be there.
Are you using the Gutenberg editor?
If so it would be on the right hand side.
Let me know :)
Changed over to Gutenberg and found it on the right hand side as you mention. Ticked the Content Title box which has stripped out the h1 tags. Is this what you are looking for.
Doing this has not put site title in h1 tags. All it has done is removed the tags. Surely this is no answer.
If i understand correctly in place of the Content Title ie. Home you want it to display the Site Title.
If that is the case then remove the Content Title using the Disable Elements
Then edit your Page in Elementor and add in your own H1 Heading and write in your Site title.
As stated, I want the theme to show my site title in h1 tags on the home page.
As I was requested to do above, I have already removed Content Title using the Disable Elements. But was awaiting the next stage. So does Generate Press theme not automaticaly have h1 tags?
The Site Title will switch to H1 on the front page IF it is set to display the Latest Posts.
For a static home page you will need to add 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>',
( is_front_page() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
});
Using static home page. Could you please show me where abouts to add the code you provided?
oop sorry - for sure - this article explains:
https://docs.generatepress.com/article/adding-php/
TLDR: If your using a Child Theme it goes in your funtions.php. If not use the Code Snippets plugin: https://en-gb.wordpress.org/plugins/code-snippets/ to add this code.
I an using a Child Theme so will add it to the funtions.php. Can you point to where in the code to add the extra part?
<?php
/**
* GeneratePress child theme functions and definitions.
*
* Add your custom PHP in this file.
* Only edit this file if you have direct access to it on your server (to fix errors if they happen).
*/
function generatepress_child_enqueue_scripts() {
if ( is_rtl() ) {
wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
}
}
add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
I am really surprised that this theme does not have this feature already built in. As far a I was aware using the H1 tag for a post or page's title was the best option regarding the SEO of a site. So the question is. Is this a problem with my site only or are all other sites using Generate Press built the same way and have to add extra code in order to have this feature?
Sorry I'm a bit confused and I think there is a bit of miscommunication here.
As far a I was aware using the H1 tag for a post or page’s title was the best option regarding the SEO of a site.
That's exactly what GP does.
If that is so then why do I have to do the following? I am waiting for a reply about where to add this code into the funtions.php. The Site Title will switch to H1 on the front page IF it is set to display the Latest Posts.
For a static home page you will need to add 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() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
});