Come Party At The Playboy Mansion!
 

How To Make A Custom Home Page Title

written by John Chow on May 31st, 2007

I’ve received more than a few emails asking me how I got my blog home page to say “Make Money Online with John Chow dot Com” while all my other pages show the default title and blog name.

Normally, Wordpress shows the home page title as name of the blog and the tagline. In my case, it would be John Chow dot Com >> The Miscellaneous Ramblings of a Dot Com Mogul. When I decided to go after the make money online keywords, I changed the title of the home page to add those words in. However, I didn’t want to change my tagline in order to do that. This is where Justin from My PC Rig came in. Justin is a coding genius and showed me how to mod my blog header file to achieve the desired result.

Do I Hear An Echo?

To give your blog home page a custom title that is not tied to your blog name or tagline, you need to insert an echo command. Log into your server and find the header.php file in your blog theme folder. Look for the following codes. This was taken from the Mistylook theme so your header codes maybe a bit different.

<title><?php bloginfo(’name’); ?> <?php if ( is_single() ) { ?> &raquo; Blog
Archive <?php } ?> <?php wp_title(); ?></title>

Add the following echo command in front of the code that calls up the title.

<title><? if ($_SERVER["REQUEST_URI"] == "/"){
echo "Make Money Online with John Chow dot Com";
}else{
?>
<title><?php bloginfo(’name’); ?> <?php if ( is_single() ) { ?> &raquo; Blog
Archive <?php } ?> <?php wp_title(); ?></title>

If you run the Optimal Title plugin, like I do, then the codes will look like this.

<title><? if ($_SERVER["REQUEST_URI"] == "/"){
echo "Make Money Online with John Chow dot Com";
}else{
?>
<? optimal_title(’&laquo;’); ?><?php bloginfo(’name’); ?> <?php if (!optimal_title(”, FALSE)) bloginfo(’description’); ?> <? } ?></title>

What the above change does is tell Wordpress to use the standard name and tagline as the title for every page except the home page. If a reader goes to the home page, it will show whatever you entered in the echo.

Tweet This Tweet This Post!
English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flagCroat flagDanish flagFinnish flagHindi flagPolish flagRumanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flagSlovenian flagUkrainian flagVietnamese flag
  1. And do u use optimal title? Add an example with Optimal Title Plugin :p

    • Jez

      There is an “is_home” variable you can test against instead of testing against the URI… not that it really matters…

      • To add to this, there are a bunch of built in WP functions like this.

        is_search() — Search Query
        is_page() — Manually added “static” page
        is_post() — Normal posts
        is_single() — Is there just one item on the page (ie not front/category pages).

        I’m sure there are more, but with those you can do some tricky things.

      • Oh, and I think they are all functions..

        so you need to test using

        if (is_home()) {
        // Do Whatever.
        }

        You can also do the inverse, notice the bang (!), which basically means NOT.

        if (!is_home()) {
        // Do whatever.
        }

  2. Very nice. I didn’t even notice it until you post about it lol

  3. I’ve actually wondered how to do this. I noticed it on your blog as well as a few others. Thanks for the code!

  4. Can use SEO Title Tag plugin also.. can download it from here.. http://www.netconcepts.com/seo-title-tag-plugin/

  5. Glad you took my advice and made a post about this, now I have the information archived somewhere :)

  6. Optimal Title sucks! It’s not compatible with other plugin plus you have to dig around to configure it =(. Check out my post on the “Top WordPress Meta-Tag Plugins List” for the ‘Ultimate Meta-Tags’ plugin (scroll down to the very end :roll: and, yes, this plugin can not only insert the title tag but also pretty much ALL of the meta tags :) . Enjoy guy!

  7. Try this my friend, a recommended way

    <title>
    <?php if(is_home()) {
    echo 'Make Money Online with John Chow dot Com';
    }
    else { ?>
    <?php bloginfo(’name’); ?> <?php if ( is_single() ) { ?> » Blog
    Archive

  8. *Also, all you need for the title is these code between the title tags:

    I explain why this simple structure is the best title config for SEO on my blog. The post, I think, is under the related post entries in the above ‘Top Wordpress Meta-Tag Plugins List’.

    O.K. Gtg….

  9. Instead of hard-coding a check on $_SERVER['REQUEST_URI'], you can just use the WordPress function is_home(), i.e.

    if (is_home()) {
    // my homepage title goes here
    } else {
    // my archives/single page title goes here
    }

  10. There’s an easier function than

    $_SERVER["REQUEST_URI"] == “/”

    It’s is_home or is_page(home) or something like that… I’ll have to look it up quickly.

  11. Tony

    Wordpress out of the box is extremely bad for supplemental results.You need to add a unique page title and page description to every post. If you can’t make your own plugin which allows you todo this for every post then there are a couple of 1/2 decent plugins that do it automatically. One is called Add-Meta-Tags it isn’t perfect but it is heaps better than the standard fare from wordpress. It also automatically adds unique page titles and page descriptions to all your old posts which can be handy if you have a couple of hundred posts.

  12. Ok, anybody here can do a evil trick and create some script for other platforms like Blogger or Xanga?

    That will make a great update and greater value for John’s post, and a :twisted: linkback with good traffic.

    NOW, thats :idea: :arrow: :twisted: :arrow: :twisted:

  13. Thanks for the hack, very useful Wordpress trick.

  14. So many people giving advices.
    Well… php rocks for wordpress:) If you know just a bit of, you can make a lot.
    about $_SERVER: there’s the simple way
    is_home, or is_something… it’s on the WP framework:) Why should i look for something (waste time) when it’s so easy to just put it there?:)

    Notice: for ones that have their blogs in a subfolder, request_uri should be properly set. For those, is_home it’s the simple way:)

    And… i’m using the $_SERVER method to have a my own location for readers.

  15. nice way around. thanks to Chow & SEO Blog..

Trackbacks

  1. Joefiro.com » How To Improve Your Blog - June 6, 2007 at 7:22 am