Currently, the GeneratePress theme (affiliate link) has H2 (<h2>
) heading tags set for the sidebar widget titles.
That’s not the best on-page SEO practice.
After the H1 heading tag, H2s are the most important for your posts and pages.
They are used to structure your main content and, whenever possible and relevant, they should contain keywords.
Mixing sidebar titles like “Recent Comments” or “Recent Posts” with your main content’s subheadings is not peachy.
Therefore, in this guide, I’ll show you how to change the sidebar heading tags in the GeneratePress theme.
Change sidebar heading tags in GeneratePress
I recommend backing up the file or the website and also have a child theme in place. Here’s where you can download the GeneratePress child theme. A child theme alternative is the Code Snippets plugin.
Step 1
You’ll need to access your theme’s files and edit the functions.php
file.
The functions.php
file should usually be in:
public_html/wp-content/themes/GeneratePress_child/functions.php
If you’re doing this for your add-on domain, not your main one, then the file should usually be in:
public_html/YOURDOMAIN/wp-content/themes/GeneratePress_child/functions.php
Step 2
Add the below code right at the bottom of the file or right before the ?>
ending tag (in case there’s one).
This will change the sidebar heading tags in GeneratePress to H4 (<h4>
).
H3 (<h3>
) heading tags are still needed quite often as sub-subheadings in the main content, so it’s best if you don’t add them as widget titles in sidebars and footers.
How to check if the sidebar heading tags were changed
To check if the heading tags have been replaced, right-click exactly on one of the widget titles and select Inspect or Inspect Element (depends on the browser).
A window will appear at the bottom of the screen with the source code for the selected element, and the widget title should be the one highlighted if you right-clicked exactly on it.
As you can see, my Recent Posts widget title uses an <h4>
heading tag now.
If the changes don’t take place, clear your site and browser caches.
That’s a wrap
Hope you found the post useful and you managed to change the sidebar heading tags in your GeneratePress theme!
Don’t forget to share the post to help out others!
You can quickly subscribe to my newsletter by using this link.
If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.
You can also hit the follow button on Twitter and subscribe to the YouTube channel.
My WordPress installation service is at your disposal!
On-going WordPress support and maintenance services are on the menu as well!
Hi,
I did try adding the snippet using the code snippets plugin as I can’t find the child theme folder.
I’m currently using Marketer child theme which I got from the site library while using GeneratePress theme.
Can you please help me?
Hello!
Marketer isn’t a child theme, it’s just a pre-made template/design from the library.
The code still works for me, and I also tried it now on my testing site using the Code Snippets plugin – it works.
After you added the code in Code Snippets, did you also click the Activate button after Save? Also, clear your site and browser cache. The site’s cache can come from different places, such as plugins, server, CDN…
Thank you so much it worked but it’s h2 only on homepage apart from that I’ve checked on posts page it’s h4 only.
I was checking on homepage only and on homepage it is still showing h2 only can you please check my website –
https://www.techcrucial.com/
The blog post title is also shown in h2 heading tags, they should be in the h1 heading tag, right?
I checked your code and the widget titles handled by the theme (currently “Recent Posts” and “Categories”) are h4s on both homepage and single posts. If you see them differently, clear the caches.
The only title that’s an h2 is the one handled by the Bloom opt-in plugin (“Subscribe To Our Newsletter”), which is unrelated to GeneratePress. If possible and available, try using the title field provided by the widget, not by the plugin itself. Hopefully, that will work.
The single posts have h1 headings for the titles, which is good. The posts on the blog page (homepage) have h2 headings, which is good because they are basically subtopics on a main page, the blog page in this case.
The best practice is to have one descriptive h1 heading on every page/post. So, the blog page, which is actually the homepage for blogs, should have an h1 heading added. That way, the heading structure won’t be broken as well. Jumping straight to h2 breaks the heading structure.