Jump to content
xisto Community
imjjss

How To Populate Metadata For Your Wordpress Pages And Posts manage metadata for better SEO result in WordPress

Recommended Posts

I was with other software before I fall for WordPress-- one of the most powerful content management software. While I enjoy the vast features WordPress presents, I do feel something missing-- where to write the page descriptions and keywords. I've got used to write those stuffs when building pages in other software. Now with WordPress, I can't find a place to enter those stuffs. I felt bothered because I've been taught that page descriptions and metadata keywords are important for search engines to determine how to category the pages.

After some search and study, with the help of my friends, I finally found my way out.

Here I going to share my finding with you-- a simple way to add keyword for SEO purpose.

Step one. Adding "keywords" field

Since WordPress doesn't provide us a way to write down our "keywords", our first job is to create a "keyword" field. Then, we will find ways to populate data into this field in following steps.

On Page or Post editing page, you have a Custom Fields panel, right? Go there, we add a new field "magicwords". For the value, you can enter any text you like for this current page or post. Our purpose here is to create a place "magicwords" to store our future inputs.

Step two Create a function to generate matadata tag

Add this code in your theme's functions.php file

function set_magicwords(){    global $post;    $magicwords = get_post_meta($post->ID, ‘magicwords’, true);    $default_magicwords = “type, in, some, default, magicwords”;    $metatag= “”;    if (empty($magicwords)){    $magicwords = $default_magicwords;    }    if (is_home() || is_front_page()){    $keywords = $default_keywords;    }    $metatag=”\t”;    $metatag.= “<meta name=\”magicwords\” content=\”";    $metatag.= $magicwords;    $metatag.= “\” />”;    $metatag.= “\n\n”;    echo $metatag;    }    add_action(‘wp_head’, ‘magicwords’);

Step three Enjoy a better SEO result

With the above funtion working atutomatically for you, everytime when you create a new page or post, it will set default metadata keywords for this page or post. You can also enter different keywords in the "magicwords" field for different pages or posts. Either way, you are done.

 

Use the same technique, we can create and populate our page description field. You can try to code it in the same way by yourself. I will write another article for the page description if necessary.

Share this post


Link to post
Share on other sites

Additional note:You should replace the "type, in, some, default, magicwords” with your own keywords, it can be comma seperated words or strings. By the way, the quote "" shows up in the code box like a special charactor. please note it is quote " "

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.