Title: Conditional Tag code not working
Last modified: August 19, 2016

---

# Conditional Tag code not working

 *  Resolved [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/conditional-tag-code-not-working/)
 * I’m trying to get a client’s “Blog” page to display a different right sidebar
   than the rest of the pages. I entered this into the page.php file of the template:
 * Where it used to say:
 * `<?php include ('sidebar2.php'); ?>`
 * I changed it to:
 *     ```
       <?php
         if (is_page("blog")) {
         echo '<?php include ('sidebar2.php'); ?>';
         } else {
          echo '<?php include ('sidebar3.php'); ?>';
         }
       ?>
       ```
   
 * This code was taken directly from a site that it works on. All I changed is what
   is in the `echo ''` part and removed some elseif lines.
 * Can anyone tell me why this isn’t working? I think it’s because I have `<?php?
   >` in there more than once but don’t know how else to write it.
 * Thanks

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

 *  Thread Starter [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/conditional-tag-code-not-working/#post-1384931)
 * Found the code by searching Google:
 *     ```
       <?php if ( is_page('blog') ) { ?>
       <?php include(TEMPLATEPATH.'/sidebar2.php');?>
       <?php } else { ?>
       <?php include(TEMPLATEPATH.'/sidebar3.php');?>
       <?php } ?>
       ```
   
 * Thanks!
 *  [Samuel B](https://wordpress.org/support/users/samboll/)
 * (@samboll)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/conditional-tag-code-not-working/#post-1384933)
 * edit – ha beat me to it

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

The topic ‘Conditional Tag code not working’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * 2 replies
 * 2 participants
 * Last reply from: [Samuel B](https://wordpress.org/support/users/samboll/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/conditional-tag-code-not-working/#post-1384933)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
