WP: Use Post Excerpt as Meta Description

Hack header.php file in theme folder to add post excerpt as META description in single posts. I dont know why does Google give so much importance to META tags. Add the following code in in header.php. Remove META description tags if already present. Do it with your intelligence.

<?php
//if single post then add excerpt as meta description
if (is_single()) {
?>
<meta name="Description" content="Hello <?php if (have_posts()){ while (have_posts()){ the_post(); the_excerpt_rss(); }} ?>" />
<?php
//if homepage use standard meta description
} else if(is_home() || is_page())  {
?>
<meta name="Description" content="YOUR KEYWORDS FOR HOME PAGE/PAGES">
<?php
//if category page, use category description as meta description
} else if(is_category()) {
?>
<meta name="Description" content="<?php echo strip_tags(category_description(get_category_by_slug(strtolower(get_the_category()))->term_id)); ?>" />
<?php } ?>
#wordpress   #hack   #meta   #description   #php   #seo   #google   #the_excerpt