Changing the <h2> tags of your Wordpress theme’s sidebar

Erstellt am 29. Mai 2008 um 12:30 Uhr von Gonzo.

How to change the sidebar headings of your wordpress blog as part of general search engine optimization (SEO)

I finally found a solution for a problem connected to search engine optimization (SEO) of wordpress blogs, which I have been thinking about for quite a long time: How could you change the <h2> tags of the widgets in the sidebar to lower heading tags like h4 or h5 in order to optimize the heading structure of your wordpress blog?

The solution is quite easy. Just replace the code in your theme’s functions.php with the following (inspired by this article):

<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'sidebar1',
'before_title' => '<h5>', // Replaces <h2>
'after_title' => '</h5>', // Replaces </h2>
));
register_sidebar(array('name'=>'sidebar2',
'before_title' => '<h5>', // Replaces <h2>
'after_title' => '</h5>', // Replaces </h2>
));
?>

This will register up to two sidebars to your blog, where the <h2> headings of the widgets in the sidebar are now replaced with <h5> tags. Of course you can change h5 to whatever you want (please note that if you want to keep some functions of your original functions.php, you should not just replace it… :) ). In addition to that you should manually replace the <h2> tags in the sidebar.php of your theme as well.

This operation is very helpful in order to optimize your wordpress blog for search engines like Google, as it heavily reduces the inflationary usage of <h2> tags in most wordpress themes. <h2> should be used exclusively for sub-headings within your posts.

Basic reading on search engine optimization and optimal structuring of your blog’s headings can be found here:

  1. Es sind noch keine Kommentare vorhanden. Schreib was schönes!

Einen Kommentar schreiben:


Achtung: Der 'Preview'-Button zeigt nur eine Vorschau an! Zum Absenden des Kommentars anschließend auf 'Post' klicken.