Title: PHP if statement not working
Last modified: August 24, 2016

---

# PHP if statement not working

 *  Resolved [jamCincinnati](https://wordpress.org/support/users/jamcincinnati/)
 * (@jamcincinnati)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/php-if-statement-not-working/)
 * In my site I have two different sidebars, one for the Blog and one for the rest
   of the site.
 * The sidebars reside in php files named _sidebar-blog.php_ and _sidebar-standard.
   php_.
 * Here is the code:
 *     ```
       <?php
       		if ( is_home( 'blog' )) : {
           			// This is the blog sidebar
           			get_sidebar( 'blog' );
       		} else {
           			// This is the sidebar for website
           			get_sidebar( 'standard' );
       		}
       		?>
       ```
   
 * The following error appears when I try to access the Blog page:
 * > Parse error: syntax error, unexpected ‘{‘, expecting ‘:’ in /home/graphic6/
   > public_html/artist_site/wp-content/themes/doublechild/index.php on line 62
 * When accessing the other pages I get the blog sidebar.
 * (The homepage has no sidebar and is unaffected)

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

 *  [MarkRH](https://wordpress.org/support/users/markrh/)
 * (@markrh)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/php-if-statement-not-working/#post-5969610)
 * The IF statement is coded wrong. Have a “:” that shouldn’t be there.
 *     ```
       <?php
       		if ( is_home( 'blog' )) {
           			// This is the blog sidebar
           			get_sidebar( 'blog' );
       		} else {
           			// This is the sidebar for website
           			get_sidebar( 'standard' );
       		}
       		?>
       ```
   
 * There are several ways to code an IF statement but you can’t mix them together:
   [http://php.net/manual/en/control-structures.if.php](http://php.net/manual/en/control-structures.if.php)
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/php-if-statement-not-working/#post-5969611)
 * Is this line 62:
 * `if ( is_home( 'blog' )) : {`
 * You’re mixing the two different if/else PHP styles. Since you’re already using
   the bracketed style, try this instead:
 * `if ( is_home( 'blog' ) ) {`
 *  Thread Starter [jamCincinnati](https://wordpress.org/support/users/jamcincinnati/)
 * (@jamcincinnati)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/php-if-statement-not-working/#post-5969794)
 * Mark, Stephen, thanks for the help.
 * The statement works but not quite the way I expected.
 * The blog sidebar shows up on all pages, not just the blog. After fooling with
   it for a day and a half I was just sitting staring at the code on the screen 
   and listening to music (Nightwish, Wishmaster album) when I realized the blog
   sidebar is called from index.php and on the other pages it is called by page.
   php. DUH!
 * No wonder half of my hair ends up on the floor when I try code this.
 * Thanks again!

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

The topic ‘PHP if statement not working’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [jamCincinnati](https://wordpress.org/support/users/jamcincinnati/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/php-if-statement-not-working/#post-5969794)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
