Title: Conditional tag and parse error
Last modified: August 19, 2016

---

# Conditional tag and parse error

 *  Resolved [Nessdufrat](https://wordpress.org/support/users/nessdufrat/)
 * (@nessdufrat)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/)
 * Hi !
    I’m trying to set different sidebars according to which page the user is
   on. I did that :
 *     ```
       <?
       if is_page('8')
       {
       function_exists('dynamic_sidebar') && dynamic_sidebar(2)
       }
       if is_page('7')
       {
       function_exists('dynamic_sidebar') && dynamic_sidebar(1)
       }
       endif; ?>
       ```
   
 * and on my page.php template,
 * `<? get_sidebar(); ?>`
 * I get a parse error, unexpected T string on line 2 on the sidebar.php.
 * “Parse error: syntax error, unexpected T_STRING, expecting ‘(‘ “
 * Can’t understand what’s wrong. Help would be greatly appreciated !

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

 *  [tech_coach](https://wordpress.org/support/users/tech_coach/)
 * (@tech_coach)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839603)
 * Hi,
 * Your second “if” should be “elseif” and you should have an else (even if it’s
   blank).
 *     ```
       <?
       if is_page('8')
       {
       function_exists('dynamic_sidebar') && dynamic_sidebar(2)
       }
       elseif is_page('7')
       {
       function_exists('dynamic_sidebar') && dynamic_sidebar(1)
       }
       else {
       	// blank - do not show a sidebar
       }
   
       endif; ?>
       ```
   
 *  Thread Starter [Nessdufrat](https://wordpress.org/support/users/nessdufrat/)
 * (@nessdufrat)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839609)
 * Actually, I did something different because my code was completly false from 
   the beginning.
 * Here is the right version :
 *     ```
       <div class="sidebar">
       <?
       if( function_exists( 'dynamic_sidebar' ) )
       {
       	switch ( is_page( $post->ID ) )
       	{
       		case "8":
       		{
       			dynamic_sidebar( 2 );
       			break;
       		}
   
       		case "7":
       		{
       			dynamic_sidebar( 1 );
       			break;
       		}
       	}
       }
       ?>
   
       </div>
       ```
   
 *  [tech_coach](https://wordpress.org/support/users/tech_coach/)
 * (@tech_coach)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839704)
 * cool! So it works now?
 *  Thread Starter [Nessdufrat](https://wordpress.org/support/users/nessdufrat/)
 * (@nessdufrat)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839719)
 * Yeah 🙂 A friend (C# programmer) helped me write this, and it works like a charm!
 *  [bjovanov85](https://wordpress.org/support/users/bjovanov85/)
 * (@bjovanov85)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839925)
 * I can’t do anything on my site. I can’t get to dashboard because whenever I type
   my URL in this comes up.
 * Parse error: syntax error, unexpected T_STRING in /home/thescri1/public_html/
   wp-includes/functions.php on line 1208
 * Someone please help!
 *  [asechrest](https://wordpress.org/support/users/asechrest/)
 * (@asechrest)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839926)
 * Did you change some code in your `functions.php` file?
 *  [bjovanov85](https://wordpress.org/support/users/bjovanov85/)
 * (@bjovanov85)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839927)
 * No, it just happened out of nowhere. One day it just didn’t work.

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

The topic ‘Conditional tag and parse error’ is closed to new replies.

## Tags

 * [conditional tag](https://wordpress.org/support/topic-tag/conditional-tag/)
 * [parse-error](https://wordpress.org/support/topic-tag/parse-error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 4 participants
 * Last reply from: [bjovanov85](https://wordpress.org/support/users/bjovanov85/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/conditional-tag-and-parse-error/#post-839927)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
