Title: Title in Header.php Tweaking
Last modified: August 19, 2016

---

# Title in Header.php Tweaking

 *  Resolved [gangles](https://wordpress.org/support/users/gangles/)
 * (@gangles)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/title-in-headerphp-tweaking/)
 * Hello all,
 * I’d like to change the title of my page (defined in header.php) from:
 *     ```
       <title><?php if ( is_home() ) { ?><? bloginfo('name'); ?>
       <?php } else {wp_title(''); ?>&nbsp;-&nbsp;<? bloginfo('name'); } ?></title>
       ```
   
 * To:
 *     ```
       <title>
          <?php if(is_home()) { } ?>
          <?php elseif(is_404()) { ?>
            404 (Page Not Found) -
          <?php } ?>
          <?php elseif(is_search()) { ?>
            Search Results for <?php echo wp_specialchars($s, 1); ?> -
          <?php } else { ?>
          <?php wp_title(); ?> -
          <?php } ?>
          <?php bloginfo('name'); ?>
       </title>
       ```
   
 * However, it’s giving me the following error:
 * > Parse error: syntax error, unexpected T_ELSEIF in /wp-content/themes/default/
   > header.php on line 10
 * I’m a bit fresh when it comes to PHP, and I can’t figure out exactly what is 
   wrong with my code syntax. Any help would be much appreciated.

Viewing 1 replies (of 1 total)

 *  Thread Starter [gangles](https://wordpress.org/support/users/gangles/)
 * (@gangles)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/title-in-headerphp-tweaking/#post-893300)
 * Fixed code (and much cleaner)!
 *     ```
       <?php
          if(is_home()){
            echo "";
          }
          elseif(is_404()){
            echo "404 (Page Not Found) - ";
          }
          elseif(is_search()){
            echo "Search Results for ";
            echo wp_specialchars($s, 1);
            echo " - ";
          }
          else{
           echo wp_title();
           echo " - ";
          }
          echo bloginfo('name');
          ?>
       ```
   
 * I’m not sure if the empty echo is strictly necessary.

Viewing 1 replies (of 1 total)

The topic ‘Title in Header.php Tweaking’ is closed to new replies.

## Tags

 * [header](https://wordpress.org/support/topic-tag/header/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [title](https://wordpress.org/support/topic-tag/title/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [gangles](https://wordpress.org/support/users/gangles/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/title-in-headerphp-tweaking/#post-893300)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
