• Hello – i am new here and to WP and PHP and have a diagnostics issue. The PHP code in my template for the title in my WP site is”

    <title>
    <?php if (is_home()) { ?>
    <?php bloginfo('name'); ?>
     -
    <?php bloginfo('description'); ?>
    <?php } else { ?>
    <?php wp_title($sep = ''); ?>
     -
    <?php bloginfo('name'); ?>
    <?php } ?>
    </title>

    I am having trouble because my site: http://www.paggsupplement.com has a home page that is showing up as ” – pAGG Supplement” with all of the child pages showing up as “[Child Page Title] – pAGG Supplement” How can i alter this PHP code so the homepage doesnt have the empty Hyphen prefex and reads “Home – pAGG Supplement”?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’d rewite this as:

    <title>
    <?php if(is_home()) {
    echo  'Home - ' , bloginfo('name');
    }
    else {
    echo wp_title($sep = '') , ' - ' , bloginfo('name');
    }
    ?>
    </title>

    This will do what your looking for and be lighter on your servers resources

    Thread Starter tmasterson123

    (@tmasterson123)

    Thank you – However now the search engine is having trouble seeing my code results. Im using:

    <title>
    <?php if(is_front_page()) {
    echo  'Home - ' , bloginfo('name');
    }
    else {
    echo wp_title($sep = '') , ' - ' , bloginfo('name');
    }
    ?>
    </title>

    And when you google “pagg supplement” you only get to see ” – pAGG Supplement” for the home page instead of “Home – pAGG Supplement” for the home page as you see when you actually visit http://www.paggsupplement.com

    Thoughts?

    Review the Codex page for wp_title.

    The title might not change in Google straight away you have to wait for them the re index for page and update their records

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Help with PHP Title Tag’ is closed to new replies.