Archived topic
Problems hiding H1 Title
7 replies · Started by Tommy on March 3, 2022
I had x2 H1 titles on my archives page and put this snippet in:
add_action( 'wp', function() {
remove_action( 'generate_archive_title', 'generate_archive_title' );
} );
But I've notice the paragraph for the category is also hidden. Is there a way to only hide the H1 title and and not the paragraph? Thanks
Hi there,
odd that you should have 2 x H1 on an archive page... can you share a link to an archive so i can take a look ?
Hi David,
The second H1 appeared after I added a Headers Block. I have added the code as it's obviously bad for SEO, but here's two images of one with 2 H1 (and the paragraph there) and the other screenshot with the code that removes the second H1 title and the paragraph.
If you need me to remove the code for a bit, I can but here's a link to the page anyway...
Hi Tommy,
May we know what you’re adding the Header Block for? I can see that there is already a Title coming from a Block Element already set for this specific Archive Page.
If you set a Header Element with a {{post_title}} template tag, you would have two titles. One from the Block Element already in place and the other from the Header Element. In essence, you have two elements each displaying a title which causes the duplicate.
If you wish to apply this Header Element on your Entire site except for Archive pages for instance to avoid duplicate titles, you can set pages to exclude in the Display rules.
See: https://share.getcloudapp.com/4guK008b
Hope this clarifies.
The Header Block is a hook after_header. I'm using it just for the archive pages. I'm sure you probably know, but the title in the element is a Dynamic H1, should I change it to H2?
I think the other H1 that is hidden with the code snippet, is the actual page title. I'm wondering how to remove this without removing the paragraph underneath as in the images above.
Also, excuse the dumb question, but does using code to hide a H1 title actually remove it from the code? Eg. Will Google Bots still read x2 H1 titles because it's hidden?
To confirm there is only 1x H1 on that archive.
If you want you can add the description back in using a Block Element -> GP Dynamic Content block. You can either add that to your Hero or hook it before_main_content
Good to know, and yeah I was thinking of doing it that way, but just wanted confirmation of everything. Thanks for the advice, both of you.
Your welcome