Subscribe via RSS Feed

SEO Your Wordpress Description And Keyword Without Plugins

[ 3 ] December 21, 2009 | Abi

You can remove SEO plugins that are designed to optimize your meta description, keyword and to have canonical url feature to avoids duplicate content, the plugins that work that ways are All In One SEO Pack or Platinum SEO Pack, but we can have the same SEO even without using them and remove them from your plugin storage, by replacing their roles with PHP codes, why you want to do that? Well, Wordpress will be working much better if it’s using less plugin

Let see, we all know if using All In One SEO Pack as the result each of our page will have a unique description and keywords, they will help Google to identify our page and what is all about.

How if we use PHP code to replace their role? That sounds better

1. Ok now to have unique description you need to add the following PHP code inside Header.php (below title tag: <title> </title>)

<meta name="description" content="<?php the_excerpt_rss(); ?>" />

Note: the above code will automatically fetch the lines within the Excerpt to use as description, thus you need to write description in the excerpt box:

Describe Your Excerpt

But if there’s no lines or description in the Excerpt, then there is no description, so if you want the code to fetch description whether there is description inside excerpt or not, replace:

<?php the_content(); ?>

With the following:

<?php the_excerpt(); ?>

The code will grab description from the first paragraph of yours even there is nothing inside your excerpt box

2. Now about unique keyword, what we need is “Tag” and turn it into keywords tag, well to have it, add the following code inside your Function.php:

function csv_tags() {
$posttags = get_the_tags();
foreach((array)$posttags as $tag) {
$csv_tags .= $tag->name . ',';
}
echo '<meta name="keywords" content="'.$csv_tags.'" />';
}

And then to call the keywords, add this code (put it below description tag), now:

<?php csv_tags(); ?>

So the whole codes will look like this:

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php the_excerpt_rss(); ?>" />
<?php csv_tags(); ?>

So each of your page will have unique description and keyword now

3. Now about Canonical Url, just upgrade to Wordpress 2.9, then you will have canonical url by default!

You may be interested to read How To Make Wordpress Theme SEO Friendly Theme

Hope the post helps and see you again in the next post

Tags: , , , , , ,

Category: SEO, Wordpress

About Abi: Hi guys, check for the best hosting plans, visit this The Best Web Host View author profile.

Comments (3)

Trackback URL | Comments RSS Feed

  1. Speaking of WordPress 2.9, how’s it working for you so far? I’ve heard some good things about the latest update.

  2. It is really deep information about wordpress blog and coding too.Thanks for saring

  3. Great dude! Thanks for sharing, actually i was confuse optimizing PHP code in wordpress.