Is there anyway that I can automate the generation of META description tags? For example it automatically, unless I tell it differently, uses the first 160 characters of each post?
Thanks in advance for your help.
Is there anyway that I can automate the generation of META description tags? For example it automatically, unless I tell it differently, uses the first 160 characters of each post?
Thanks in advance for your help.
you could try and add some code like this to header.php:
<meta name="description" content="<?php
if (have_posts()) : while (have_posts()) : the_post();
$excerp = get_the_excerpt();
$excerp = strip_tags($excerp);
$excerp = preg_replace('/... » read more »/', ' - ', $excerp);
if(!is_singular()) { $excerp = substr($excerp, 0, 160) ; }
echo get_the_title().' : '.$excerp .' - ';
endwhile; endif; wp_reset_query();
?>
" />
this would echo:
- the full excerpt in single post and page,
- a 160 character shortend excerpt on index and other pages,
in the meta description tag.
This topic has been closed to new replies.