Articles - Written by Floogi on Thursday, April 24, 2008 12:45 - 1 Comment

WP’s Custom Fields For Meta Tags

I like WordPress more and more for everyday I use it. Today, I found out a quick and easy way to assign the Meta Tags, Keywords and Description to each post page, without using any plugin. WordPress has a nice built in feature, the ability to assign custom fields to your posts. By just taking advantage oft hat powerfully feature of WordPress, you can easily add your Meta Tags while writing your post, without the need of any plugin. Let me show you how to do it, it’s ridiculous easy!

In order to be able to add our own keywords and description, to each post, we are going to use the custom fields feature. This feature lets us add some extra information to our posts, for example, keywords and description, that we are going to use. The extra information that you enter in your own fields are also called Meta-data. You only need to create a field once, you can then use it from all of your posts.

Meta-data is built up with one key, that holds some kind of information. With this function, you can start building advanced WordPress themes and add very smart functions to your site. For example, add images to Featured posts, decide when they should expire etc.

Anyway, let me know show you how to the custom fields to add keywords and description to your posts, that we will use in our Meta Tags for those posts.

First of all, we must do some editing of your template. You’ll need to open up the Theme Editor, that you’ll find under the Design tab. Then open up your header template. Usually named, header.php

Now, on the two next lines after the, tag, copy and paste these two lines,

<meta name="description" content="<?php $key="Description"; echo get_post_meta($post->ID, $key, true); ?>" />
<meta name="keywords" content="<?php $key="Keywords"; echo get_post_meta($post->ID, $key, true); ?>" />

If there already exists two lines with those two meta tags, you should delete them. If, you don’t, you will have two sets of the keywords and description tags, on your pages, and that is not good SEO.

Now, save your changes and click on the Write tab and start write your new post. After you are done writing, you should scroll down and you’ll find a section named Custom Fields. Click on the little arrow to open up the Custom Fields section.

You should now see two empty fields, Key and Value. Now we are going to create the keys that we are going to use for our Meta Tags. In the first empty field, the Key field you enter,

Description

Make sure that the first letter is capitalized, and then in the Value field you write the description for the post. When your done, click on the button labeled, Add Custom Field.

Now, you create another key, named

Keywords

and add the keywords that you would like to have, separated with a comma. When your done, you click just click the add button again.

Now, we are almost finished, all you need to do now, is to publish your post. Now, you should be able to see, you keywords and description, if you visit your new post and select View Source, in your browser!

Now, since the keys are stores, you only need to enter new values, for your next post. Of course, you can go back and add keywords and descriptions to all your previous post, too.

There is how you use the custom fields to generate your own meta tags, without using any WordPress plugin!



1 Comment

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

melihkagan
Jun 23, 2008 5:05

Thank you for your post. It really worked after some effort. At my first trials I get an error. After some investigation, I found the reason. I would get your attention on the question marks, if you copy and past the HTML code.

<meta name=”description” content=”ID, $key, true); ?>” />
<meta name=”keywords” content=”ID, $key, true); ?>” />

I rewrite the question marks above and finally, the code works fine.

Leave a Reply

Comment

Most Popular Content

More In


More In


More In