Title: Header Code Trouble
Last modified: August 20, 2016

---

# Header Code Trouble

 *  [Ganjanator](https://wordpress.org/support/users/ganjanator/)
 * (@ganjanator)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/header-code-trouble/)
 * I’m a newcomer to web development and WordPress, and the below block of code,
   which is supposed to change the title based on the current page, causes this 
   error message to appear: “Parse error: syntax error, unexpected ‘{‘ in C:\xampp\
   htdocs\wordpress\wp-content\themes\Suravara\header.php on line 8” (line 8 is 
   the second line, after the opening php tag). Can anyone help me out wiith this
   surely simple error? Thanks!
 *     ```
       <?php
       if ( is_single() ) { single_post_title(); }
       elseif ( is_home() || is_front_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); get_page_number(); }
       elseif ( is_page() ) { single_post_title(''); }
               elseif ( is_search() ) { bloginfo('name'); print ' | Search results for ' . wp_specialchars($s); get_page_number(); }
               elseif ( is_404() ) { bloginfo('name'); print ' | Not Found'; }
               else { bloginfo('name'); wp_title('|'); get_page_number(); }
           ?>
       ```
   

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

 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/header-code-trouble/#post-2291465)
 * Can you paste all the header.php not here but to [pastebin](http://pastebin.com),
   and paste the link back here, the code looks fine, so it could be an open tag
   before this one?
 * David
 *  Thread Starter [Ganjanator](https://wordpress.org/support/users/ganjanator/)
 * (@ganjanator)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/header-code-trouble/#post-2291634)
 * [ Here You Go. Thanks! ](http://pastebin.com/WsNdAn2E)
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/header-code-trouble/#post-2291645)
 * Untested Try:
    [http://pastebin.com/XMa41AM9](http://pastebin.com/XMa41AM9)
 * If I am correct with single lines we do not need the braces {}
 * `if ( is_single() ) { single_post_title(); }`
 * This just becomes:
    `if ( is_single() ) single_post_title();`
 * If there is more than one line nested in the statement then we do need the braces.
 *     ```
       elseif ( is_home() || is_front_page() ) {
          bloginfo('name'); print ' | ';
          bloginfo('description'); get_page_number();
       }
       ```
   
 * HTH
 * David
 *  Thread Starter [Ganjanator](https://wordpress.org/support/users/ganjanator/)
 * (@ganjanator)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/header-code-trouble/#post-2291648)
 * If I take the ‘{‘ and ‘}’ from line 8, the error becomes
    Parse error: syntax
   error, unexpected ‘{‘ in C:\xampp\htdocs\wordpress\wp-content\themes\Suravara\
   header.php on line 9, and I’m pretty sure the else if on line 9 needs the braces
   because of multiple statements

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

The topic ‘Header Code Trouble’ is closed to new replies.

## Tags

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

 * 4 replies
 * 2 participants
 * Last reply from: [Ganjanator](https://wordpress.org/support/users/ganjanator/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/header-code-trouble/#post-2291648)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
