I have been usign a theme for one of my wordpress powered sites which was lacking a description tag in the header. With this tag lacking, my site’s results on google search returns some junk from each page as the description which is horrible. I found the following code and added it to my site. Now my descriptions are beautiful and my SEO has greatly improved. Dynamic head tags are frickin’ awesome!
Thanks to Nathan Rice for the code.
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name=”description” content=”<?php the_excerpt_rss(); ?>” />
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name=”description” content=”<?php bloginfo(‘description’); ?>” />
<?php endif; ?>



(4.67 out of 5)