WordPress SEO H1 Header Tags

wordpress seo

I can’t believe how many wordpress themes out their tag themselves as seo-friendly and some even have seo in their theme name and they don’t even do the #1 most important use of the h1 tag. Do yourself a favour if you’re a theme designer and use the following:

The h1 tag should be used for the blog title or blog description but only on the home page. On all other pages, we should relegate it to a h2 at most and put more relevance to the post titles by promoting them to a h1.

To do that, make use of the is_single and is_page wordpress functions in your header.php and alternate your h1 h2 blog title tags:

<?php if(is_single() OR is_page()) {
// On single post pages and static pages we use this code
?>
<h2><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h2>
<div class="description"><?php bloginfo('description'); ?></div>
<?php }
else {
?>
<h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
<div class="description"><?php bloginfo('description'); ?></div>
<?php } ?>

Now in you single.php and page.php, update your the_title() to h1

<h1 class="single"><a rel="bookmark" href="<?php the_permalink() ?>"></a></h1>

Now because we are using the h2 and h1 tag in the header interchangeably, make sure you style.css caters for both and they look the same

#header h1, #header h2 { font-family: Georgia, "Times New Roman", Times, serif; font-size: 25px; font-weight: normal; padding: 0em 0 0.2em 0; }

do the same for the post title h2 tags in the home page if you need to.

How to make the Sitemap Plugin work for WordPress mu

I use wpmu (soon to be named wordpress multisite – wpms?) for most of my many mini niche sites. It makes it easy to install, backup, and whip up new sites.

Arne’s google sitemap generator is the best sitemap plugin period so rather than use anyone else’s custom wpmu sitemap solutions, I’ve opted to hack Arne’s.

Way back in 2006, I used to hack the default InitOptions() function to use a manual file location. Nowadays, I find it much easier to just change what it thinks is the default location.


function GetHomePath() {
/* comment everything out and just have the following line */
return ABSPATH . UPLOADS;
}

Next, I need to make sure that the wordpress upload directory has already been created.

function BuildSitemap() {
global $wpdb, $posts, $wp_version;
$this->Initate();

//workout what the upload directory for this blog is
$upload_dir = ABSPATH . UPLOADS;
//create the directory if it does not already exist
wp_mkdir_p($upload_dir);

...

That’s it. Simple. Now just redirect all requests for the sitemap to the generated file location. Here I use .htaccess files

#sitemap
RewriteRule ^sitemap.xml$ wp-content/blogs.php?file=sitemap.xml [L]
RewriteRule ^sitemap.xml.gz$ wp-content/blogs.php?file=sitemap.xml.gz [L]

That’s it. Works for Google Sitemap Generator v3.2.2