Support » Themes and Templates » Chaning META Description in PHP

  • Anyone got any input if I had to make the following change to the php code in my theme.

    At the moment I’m finding Google SERP’s are sometimes showing my blog domain address and tagline as the description instead of a description specifically about the post/page.

    Having a look at my themes code I can see the following code:

    <meta name=”description” content=”<?php bloginfo(‘name’); ?> – <?php bloginfo(‘description’); ?>” />

    I have read that maybe using the following code would be better for customization:

    <?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; ?>

    Do you think the second code would solve the problem and better for META description?

  • The topic ‘Chaning META Description in PHP’ is closed to new replies.