HOME       >>       Websites and Web Designing

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


imjjss

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.


imjjss

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 " "


d31clubph

Thanks for the code snippet... I'll use this in my next blog.



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.