WordPress.org

Ready to get started?Download WordPress

Forums

Chaning META Description in PHP (1 post)

  1. totalgaz
    Member
    Posted 3 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic