Add Meta Descriptions To Your Posts

The problem. WordPress, surprisingly, does not use meta description tags by default.
Sure, for SEO, meta tags are not as important as they used to be. Yet still, they can enhance your blog’s search engine ranking nevertheless. How about using custom fields to create meta description tags for individual posts?
The solution. Open your header.php file. Paste the following code anywhere within the <head> and </head> tags:
view plaincopy to clipboardprint?

<meta name="description" content="
<?php if ( (is_home()) || (is_front_page()) ) {

echo ('Your main description goes here'); } elseif(is_category()) {
echo category_description(); } elseif(is_tag()) {
echo '-tag archive page for this blog' . single_tag_title(); } elseif(is_month()) {
echo 'archive page for this blog' . the_time('F, Y'); } else {
echo get_post_meta($post->ID, "Metadescription", true); }?>">
Code explanation. To generate meta descriptions, this hack makes extensive use of WordPress conditional tags to determine which page the user is on.
For category pages, tag pages, archives and the home page, a static meta description is used. For posts, the code looks for a custom field called Metadescriptionand use its value for the
meta description.
Theme images by fpm. Powered by Blogger.