AKA Marketing.com Logo

Blogged thoughts, is our web blog. Expect views, opinion, rants and tirades about everything and anything 

« Home / Services / Forums »         Organic Search Engine Optimization (SEO) Solutions. Call now on +00-353-879807629

Subscribe to our SEO / IT related blog by entering your email address below

Blogged thoughts

| by the www.akamarketing.com team



Using Wordpress conditionals for search engine optimisation purposes

In the last post I talked about the various things which you could do to optimize Wordpress for the search engines without actually changing any code, so it was all simple stuff really and kind of general. In this, the promised followup post (I’ve changed the title around for SEO purposes) I will get a little bit more technical and make use of what’s known as Wordpress conditionals. Wordpress conditionals are tags which can be used to tell Wordpress what content should be outputted on its various pages. The idea with Wordpress conditionals is exactly the same idea as conditionals in standard programming logic, for example ‘if something is true do this, else do this’ or conversely ‘if something is not true so this, else do this’.

In terms of search engine optimization Wordpress isn’t bad ’out of the box’ and therefore no use of code conditionals is actually required however like many other web systems there is always room for improvements here and there, often it is these little improvements which make the difference between 1st page and 2nd page listings for your posts in the Google, Yahoo and MSN SERPS (search engine results pages) so I definitely do recommend implementing these changes in the fullest manner possible.

You should know that all the following code modifications for SEO purposes are done to the file header.php (which is in the themes folder), if you are planning to implement any of my suggested changes I strongly recommend you make a backup copy of this file first.

To begin then lets have a look at how we can improve the keyword density of the main blog page and the main category pages by using the is_home() and the is_category() conditionals. By default on the main page Wordpress will simply start outputting your posts one after another, however if you have a look at this blogs main page you will see I have an introductionary paragraph which not only allows me to improve keyword density itself but also allows me to have my keywords closer to the top of the page than otherwise would have been possible. To do this I added code similar to the following at the very end of my header.php file:

if(is_home()) { echo “keyword rich blog description here“; }

The above line basically means that if the current page is the blog homepage then output the text in bold. Next up is the category pages, what I propose doing is writing a keyword rich introductionary paragraph for each category on the blog. The idea is the same as the one on the homepage except rather than an overall description these descriptions will be specific to the category page being viewed. As of yet I haven’t implemented these changes myself but am planning to get around to it depending on what my rankings are like in a month or two (after the redesigned site is fully spidered).

To continue then if you have a look at the official conditional tags page you will see that the is_category() tag can be used in a number of ways depending on what condition you want to check. I suggest using the is_category() tag parameterized by an ID corresponding to a certain category on your blog. To view the IDs of your categories go to the ‘Manage’ page in your admin interface and then go to the ‘Categories’ page, you should see all your categories listed out one after another with their corresponding IDs on the left.  Armed with your all your category IDs you can now make use of the is_category() tag by using code similiar to the following:

if(is_category(’3‘)) { echo “keyword rich category description here“; }

This code should be placed at the very end of the header.php file (well actually placing it above the is_home() tag is OK too, but make sure it appears after all of header.php’s original content) and will check if the archive page for the category with an ID of ‘3′ is currently being viewed and if so will output the text in bold. In the case of this blog, the category with an ID of ‘3′ is the SEO category so the bolded text above would probably read something like ‘Search engine optimisation related blog postings. Learn how to improve your rankings on Google, Yahoo and MSN, learn about the Google Sandbox, learn all about Wordpress search engine optimization……‘. The idea is to provide a fairly specific description of what’s actually on that page, that means mentioning the titles or a rewording of your titles. Google and the other search engines like to see keywords spread out over the page, older posts would of course be nearer to the bottom of the category archive page and thus their related keywords would be concentrated in that area so by having your post titles or rewordings of your post titles in the category archive description you should improve your chances of ranking well. Obviously you can’t cater for all posts in a category so I’d suggest that you give your older ones priority.

Next I’ll move onto optimizing the title tags of the various Wordpress pages. As you most likely know what’s contained within the title tag of a page has a major influence on how Google and the other search engines see that page so it’s quite important that Wordpress is optimised to the max in this respect. I’ll be making use of the is_home() and is_category() conditional tags again but I will also be using the is_single() tag too.

I have already implemented these changes which I’m about to recommend and thus I can’t exactly show you before and after examples on this blog, so that is why I will make reference to another Wordpress blog which is unoptimized (but which still ranks well due to large numbers of incoming links). The blog is a very high profile blog run by Google employee Matt Cutts blog and is located at http://www.mattcutts.com/blog/.

In terms of the actual blog posts themselves by default Wordpress places the name of the blog first then a ‘»’ and only then will it output the actual title of the post currently being viewed, for an example of this see Matt’s post entitled ‘Review: Winning Results with Google AdWords‘. Notice how the title of the post only comes after the name of the blog ‘Matt Cutts: Gadgets, Google, and SEO’. It is well known that words which occur near the start of the title tag have more weight with the search engines so obviously this default set up must be changed for maximum optimzation, this is done by having the title of the blog post appear first in the title tag, this can then by followed (if desired) by the name of the blog. The is_single() conditional tag can be used for this, this tag checks if any single post page is currently being displayed.

The title tag section of unoptimized Wordpress blogs should look something like this:

<title><?php bloginfo(’name’); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>

To reorder the title tag to make it more appealing in terms of SEO, the above code needs to be changed to the following (now is the perfect time to make that backup if you haven’t already done so):

if ( is_single() )
{
?>
<title>
<?php wp_title(’ ‘); ?>
<?php if(wp_title(’ ‘, false)) { echo ‘ » ‘; } ?>
<?php bloginfo(’name’); ?>
</title>
<?php
}

The code first checks if any single page is being currently being displayed and if so enters the inner code section. In this section the wp_title() tag outputs the title of the current page and then sets the separator (which gets prepended to the bloginfo(’name’) variable) before outputting the name of the blog. Since the above code only deals with single pages it is of course part of a set of ‘if’ and ‘else’ conditional checks but that’s the actual post pages themselves taken care of, lets look briefly at the code to display the homepage title then (to be pasted below the above code):

else
{
if(is_home())
{ ?> <title><?php bloginfo(’name’); ?> SEO Blog | Irish / Ireland Technology Blog | Search Engine Optimisation blog<?php wp_title(); ?></title>
<? }

The text in bold is the only real change from the default homepage title here, I have added these words because the name/title of my blog (blogged thoughts) is not keyword rich so these should help in the SERPS. As for category page titles Wordpress is not the best it could be as it once again places the name of the blog before the name of the category which hampers search engine optimisation. In this case though I recommend more than a simple reversal of blog name and category name, I recommend ditching the blog name altogether and simply describing the current category in keyword rich terms (for your most important categories anyhow). In the code below I ditch the category name too, this might effect usability and thus whether you do this or not is up to you.

elseif (is_category(’3′))
{ ?> <title>SEO Blog | search engine optimisation | Google optimization blog</title> <?}
elseif (is_category(’8′))
{ ?> <title>Irish technology Blog | Ireland IT news | General Irish blog</title> <?}

At this stage the code should be kind of self-explanatory but if not, the code checks if the current page being displayed is the category page corresponding to an ID of either ‘3′ or ‘8′ and displays the appropriate keyword rich title. Click into the archive pages for either the ‘SEO‘ or ‘Ireland‘ categories on this blog and you will see the above titles, however the code so far only deals with single post pages, homepage and two specific categories, finally I need to provide some default code which will cover all other pages including category pages which I have not explicitly handled in the above code. This code goes below the above code and is as follows:

else 
{ ?> <title><?php bloginfo(’name’); ?> <?php wp_title(); ?></title> <? } } ?>

It outputs the name of the blog followed by the title of the currently being viewed page. Well there you have it, by using the above code you should be able to increase the rankings of your blog and its posts on the major search engines. Remember though as I mentioned in an earlier post that onpage optimization is only really a small part of what can be and has to be done to improve your rankings so be sure to also apply offpage optimisation methods to your blog and its posts also. As usual I appreciate your thoughts and comments on this post. I think I’ll cover some non SEO stuff for the next few posts.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Digg
  • Furl
  • YahooMyWeb
  • Reddit
  • Simpy
  • De.lirio.us
  • StumbleUpon
  • Technorati
  • Netscape
  • Spurl
  • blogmarks
  • blinkbits
  • SphereIt
  • Slashdot
  • Ma.gnolia
8 Comments on “Using Wordpress conditionals for search engine optimisation purposes”
1| Bob Sutton said,

I think this is a very smart use of WordPress conditionals and not well-documented in the Codex articles on optimizing WordPress for SEO. While I recently found a plugin that manages this for me, I’m going to apply your suggestion to tags. Most WordPress themes reuse a header.php template that produces output where blog name is repeated on every page. Unless I’m missing something, a category page title or a single post’s permalinked title is the content that should receive treatment.

2| Bob Sutton said,

Oops. Didn’t realize that my h1 tags with angle brackets would disappear in your comment markup. My comment should read:

“While I recently found a plugin that manages this for me, I’m going to apply your suggestion to h1 tags. Most WordPress themes reuse a header.php template that produces output where h1 blog name /h1 is repeated on every page. Unless I’m missing something, a category page title or a single post’s permalinked title is the content that should receive h1 treatment.”

Perhaps you could just edit my first comment and toss this one?

3| David Callan said,

Ah not to worry Bob, I’ll just approve them both. I can tell you writing markup in wordpress blog posts is a pretty big nightmare.

Anyhow yes I reckon you should give some of these suggestions and go and then be sure to let us know how you get on further down the road. I’d be very interested to know.

4| AskApache.com » SEO in Wordpress said,

[…] Using Wordpress conditionals for search engine optimisation purposes (http://www.akamarketing.com/blog/31-using-wordpress-conditionals-for-search-engine-optimisation-purposes.html) […]

5| Brandon Hall said,

Talk about getting in-depth with Wordpress SEO. I see a lot of stuff here that you know most blog owners aren’t doing. I know I wasn’t. I’ve always relied on keyword titles, my ping list and tagging for SEO purposes. Thanks for a great post!

6| SEO para Wordpress said,

[…] Using Wordpress conditionals for search engine optimisation purposes […]

7| Annerose said,

These comments have been invaluable to me as is this whole site. I thank you for your comment.

8| The 3 Most Important WordPress Documentations to Help You Build SEO Blogs : WordPress Profit said,

[…] Using Wordpress conditionals for search engine optimisation purposes (http://www.akamarketing.com/blog/31-using-wordpress-conditionals-for-search-engine-optimisation-purposes.html) […]

Leave a Comment
Name:
Email:
Website: