WordPress SEO – Optimize Post Title Tags In Your WordPress Theme

wordpress seo

According to Wikipedia, WordPress was used on more than 200 million websites by the end of 2009. This is huge for any CMS on the market, more so for an open source blogging platform. I won’t get into what made WordPress CMS spread so much, as this is not the purpose of this post. I’ll only point out one of the things that contributed to this tremendous spread of WordPress: it’s templating system, the ease of customizing its themes and the great number of free and premium WordPress themes available.

However, despite the huge number of WordPress themes on the market and the “boom” in theme development for WordPress powered websites, one thing I’ve noticed in most of the themes I’ve tested and the new ones that come out: a very non-SEO choice of html tags for the blog and post titles, leading to a decrease of SEO power of the title tags. To understand what I’m talking about, let’s take a look at the HTML coding of the default WordPress theme – that probably served as a model for a lot of the themes available now.

If you look at the home page coding you will see the blog title being tagged as H1 and post titles as H2. This is very good for the home page. Now let’s go on a category or tag page. Here you will see the blog title again as H1, category title as H2 and post titles as H3 tags. Let’s navigate even deeper and go to a single post page. Here we have the blog title AGAIN as H1 while the post title is tagged as H2.

Now, what’s wrong with this picture. Well, for the average user, who has no idea about search engine optimization, html tags and organic SEO, search engine results pages and the hard battle to get to the top of them, everything is fine. But if you are not the average user and fight “inch by inch” for a higher place in SERPs for your WordPress blog then read ahead to see what’s wrong with this HTML tagging for your blog titles.

First of all, the H1 tag should be used on the most relevant phrase of each page (most of the times this is the page title) and this phrase should NOT repeat itself (or at least not too many times) among your site pages. So, having your blog title used as H1 on ALL your blog pages is a BIG mistake. According to the logic above, the blog title should be marked as H1 on the home page, the category name should be H1 on category pages, the tag name should be H1 on tag pages and the post title should be tagged as H1 on single post pages (post detail page). Except for the homepage, I would recommend using H3 or H4 tags to mark up the blog title.

Secondary, the list of H2 tags should mark up the most important subtitles on each page. This means that, on a category, tag, archive or search page, H2 tags should be set on the post titles since they act as a list of subtitles for that category, tag, archive or search page. According to the same logic, the widgets titles and subtitles, widgets that go on the sidebars and most of the times repeat on all the pages, thus losing much of the SEO juice, should be tagged as H3 and H4.

To summarize all the above you should have:

On home-page

  • H1 for blog title
  • H2 for post titles

On category, tag, archive and search pages

  • H4 for the blog title
  • H1 for the category, tag, archive title or search tearm
  • H2 for the post titles

On single post page (page detail page)

  • H4 for the blog title
  • H1 for post title
  • H2 for related posts titles (if you have something like that on your pages)
  • Maybe H3-H4 for category and tags links

Now here’s the code changes you need to do in order to get this html tagging on your theme. Go to your theme folder (/wp-content/themes/your-theme/) and edit the following files:

header.php (edit the tags for the blog title)

Find a line that looks something like this
<h1><a href=”<?php echo get_option(‘home’); ?>/”><?php bloginfo(‘name’); ?></a></h1>
and change it to
<?php if(is_home()) { ?>
<h1><a href=”<?php echo get_option(‘home’); ?>/”><?php bloginfo(‘name’); ?></a></h1>
<?php } else { ?>
<h4><a href=”<?php echo get_option(‘home’); ?>/”><?php bloginfo(‘name’); ?></a></h4>
<?php } ?>
Don’t forget to edit the CSS in order to make the H4 title tag look like the H1 tag on the home.

archive.php (category, tags, author, archive pages)

Find the list of H2 tags that looks something like
<h2>Archive for the…</h2> (somewhere close to top)
and change all these to H1
<h1>Archive for the…</h1>

single.php (single post page)

Find the line that looks like
<h2><?php the_title(); ?></h2>
and change it to
<h1><?php the_title(); ?></h1>

search.php (search results pages)

Find the line that looks like
<h2>Search Results</h2>
and change it to
<h1>Search Results</h1>
and even better, replace it with
<?php $key = wp_specialchars($s, 1); ?>
<h1>Search Results for "<?php print $key; ?>"</h1>

Don’t forget to edit your CSS to make H1 tags look like H2 inside your theme.
That’s it! Enjoy much better search engine ranking for your post titles, categories and tags.