PHP Code, SEO Optimization, Web

Hacking WordPress to be More SEO Friendly

Much effort is spent on SEO optimization, to get sites/pages top SERP (Search Engine Ranking Position). But just being the first in the list doesn't guarantee that you'll be the first clicked, or even clicked at all for that matter. The results that the search engine shows still needs to appeal to the searcher. The code snippet will show how to hack WordPress templates to be more searcher-friendly; attract the eye more easily.

By default, WordPress displays the title of the page as [Blog name] » [Category/post name]. If your blog name is not directly related to every piece of content, the search engine results may appear somewhat irrelevant. For example, if your blog is named "A Complete Waste of Time", but your content is about programming code, people who search for that code may not be compelled to click on something that will waste their time. So it make sense to switch the title around, and the code below changes the title to [Category/post name] » [Blog name] .

Also, for those search engines that still use Meta tags (such as MSN, Yahoo), it would be good to supply a description, using the excerpt from the post.

The code below gets placed in the 'header.php' of your WordPress template.


<title><?php wp_title($sep = ''); ?> <?php if (is_single()|| is_category()) { echo("&raquo;");} ?> <?php bloginfo('name'); ?></title>
<meta name="description" content="<?php if ( is_single() ) {
        the_excerpt();
    } else {
        bloginfo('description');
    } ?>" />
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image