Title: Title different to button?
Last modified: August 19, 2016

---

# Title different to button?

 *  Resolved [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/)
 * Odd one this, i’ll try and explain.
 * Is there anyway i can have say home page.
 * So it prints ‘Home’ in the main navigation.
 * However, when you go to the home page the body title, the `<?php the_title();?
   >` actually says.
 * Welcome to my site.
 * Or whatever?
 * Anyway to do it rather than taking out the title code and handcoding it in, in
   a template?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159305)
 *     ```
       <title><?php if(is_front_page()) echo 'Welcome to my site';
       else wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
       ```
   
 *  Thread Starter [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159311)
 * Wow thanks for that.
 * Mind explaining what it does?
 * Many thanks 🙂
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159326)
 * `if(is_front_page())` = is this the front page of the site?
    If it is, show (
   echo) the welcome message. If it isn’t (else), show the post title followed 2
   left angle quotes (`&laquo;`) and the blog name
 *  Thread Starter [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159333)
 * I see thanks for that.
 * I assume this would only work with the front page, could add a page id?
 * For example this is page id 40 print this instead of page name?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159347)
 * For a particular page, use `is_page()`:
 * `is_page(’40’)
    is_page(‘About Me’)
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159420)
 * So to include that in what esmi posted before the top line of what was posted
   before becomes….
 * `<title><?php if(is_front_page() || is_page('YOURPAGENAME')) echo 'Welcome to
   my site';`
 * …incase you wanted a break down …. 🙂
 * The `||` simply means or, so if it’s the front page or a page named “YOURPAGENAME”(
   in the example).. *minus quotation..
 *  Thread Starter [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159435)
 * Thanks esmi/t31os
 * I need it to work in a particular way, not the browser title but in the main 
   body title above the main body text.
 * So..
 *     ```
       <h2>
       <?php if(is_front_page()) echo 'Welcome to'; ?> <?php bloginfo('name');  echo 'test name'; ?> </h2>
       ```
   
 * Works great but there is no space before ‘test name’
 * Also a range of pages needs its own title, can this be done.
 * For example..
 * If home page the above one..
    If is_page(23): print welcome to page 23,If is_page(
   24): print this is page 24,If is_page(25): print important page 25,If is_page(
   26): print different page 26,If is_page(27): print welcome to page 27 etc etc
 * Can that be done?
 * Gave it a go here but didnt work 🙁
 *     ```
       <h2>
       		<?php if(is_front_page()) echo 'Welcome to'; ?><?php bloginfo('name');  echo 'Test Blog'; ?>
       		<?php if(is_page(23) echo 'welcome to page 23';?>
       		<?php if(is_page(24) echo 'this is page 24'; ?>
   
       		</h2>
       ```
   
 * Thanks 🙂
 *  Thread Starter [jezthomp](https://wordpress.org/support/users/jezthomp/)
 * (@jezthomp)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159450)
 * Manged to get this one working, the best way to do it though?
 *     ```
       <h2><?php
   
       if(is_page(21))
       {
       	echo 'Welcome to my home page';
       }
       elseif (is_page(23))
       {
       	echo 'this is page 23';
       }
       elseif (is_page(24))
       {
       	echo 'this is page 23';
       }
   
       ?></h2>
       ```
   
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159466)
 * Nothing wrong with what you have…
 * I’d personally do it this way, but there’s not going to be any measurable difference
   between the 2 pieces of code..
 *     ```
       <?php
       if(is_page(21)) { $title_msg = 'Welcome to my home page'; }
       elseif (is_page(23)) { $title_msg = 'this is page 23'; }
       elseif (is_page(24)) { $title_msg = 'this is page 24'; }
       else { $title_msg = 'Default message'; }
       ?>
       <h2><?php echo $title_msg; ?></h2>
       ```
   

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

The topic ‘Title different to button?’ is closed to new replies.

 * 9 replies
 * 3 participants
 * Last reply from: [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/title-different-to-button/#post-1159466)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
