Thursday, May 1, 2014

Wordpress: Adding a meta description field to your theme

Add this after the title tag in the header.php file of your theme:

 <?php if ( (is_home()) || (is_front_page()) ) { ?>  
 <meta name="description" content="<?php bloginfo('name'); ?>" />  
 <?php } else { ?>  
 <meta name="description" content="<?php the_title();?>"/>  
 <?php } ?>

Update: Using the "Add Meta Tags" plugin is a much better option...