• Yesterday someone very kindly wrote a bit of code [mod: link to that topic: http://wordpress.org/support/topic/how-can-i-make-the-homepage-title-different-from-the-navigation?replies=14 ] for me to change my page title to being different from the navigation title on my home page. It worked but I just noticed that the titles of all the other pages have disappeared. Would someone be able to look at the code and see if something is missing or needs to be added?

    function my_set_title($title) {
      if (is_front_page()) $mytitle = "Welcome to Equine Sites";
      if (in_the_loop()) return $mytitle; else return $title;
    }
    add_filter('the_title', 'my_set_title');

    It is in the function.php. Originally it was is_home but because my site homepage is set as front page I changed it to is_front_page – it didn’t work with is_home. My site is http://www.equinesites.co.uk

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why not just install a SEO or Title plugin that you can just change the titles on the pages or posts instead of coding functions?

    Thread Starter miskettie

    (@miskettie)

    Thanks for the suggestion. I have just tried this using ‘All-in-one SEO’ and it didn’t work, so tried the simple ‘Simple SEO (Search Engine Optimization)’, which didn’t work either. The ‘Home’ title on the front page doesn’t change.

    Am I doing something wrong? (As you can probably guess I am a novice at this!). The above code did work, just made all the other titles disappear! Thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    maybe this [untested]:

    function my_set_title($title) {
      if (is_front_page() && in_the_loop()) {
        $title = "Welcome to Equine Sites";
      }
      return $title;
    }
    add_filter('the_title', 'my_set_title');

    Thread Starter miskettie

    (@miskettie)

    That works! Perfect – thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Titles not showing!’ is closed to new replies.