WordPress.org

Forums

Change title tag on Index page only (4 posts)

  1. rabramson
    Member
    Posted 4 years ago #

    Hello,

    I recently added this line of code to my header.php file so that the name of the post appears in the individual post title tag: <title><?php wp_title('-','true','right'); ?><?php if ( is_single() ) ?><?php bloginfo('name'); ?></title>

    However, I would like my index page to have a unique title tag that will not appear in other title tags of my site.

    Can someone tell me which template needs to be altered and what new tag needs to be inserted?

    Note I am using the Copyblogger theme.

    Many thanks,

    Randy

  2. alchymyth
    Forum Moderator
    Posted 4 years ago #

    use a conditional tag to enter the title tag for the index page;
    example:

    <title><?php if( is_front_page() ) { echo 'unique title tag'; } else { ?><?php wp_title('-','true','right'); ?><?php if ( is_single() ) ?><?php bloginfo('name'); ?><?php } ?></title>

    http://codex.wordpress.org/Conditional_Tags

  3. CounterDax
    Member
    Posted 4 years ago #

    Do watch out with using the is_front_page() function since in some cases, such as with custom front pages, it will also return true when on a custom articles front page (thus not only the cover front page)...

    In that case, you can filter for the page name, too:

    <title><?php
    if( is_page('page-slug-or-name-or-id') ) {
      echo 'unique title tag';
    } ?></title>

    Mix and match till you get what you want.

  4. rabramson
    Member
    Posted 4 years ago #

    Thanks, everyone...I will try it!

Topic Closed

This topic has been closed to new replies.

About this Topic