Title: Conditional Tags if else question
Last modified: August 20, 2016

---

# Conditional Tags if else question

 *  [databell96](https://wordpress.org/support/users/databell96/)
 * (@databell96)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/conditional-tags-if-else-question/)
 * I’ve doing a rather lengthy where different scripts are called depending on the
   page. Problem is I have a syntax error on my script and I’d like to figure out
   where my error is. This is a condensed version of my code:
 *     ```
       <?php if ( is_page( ( 3 ) {
       <script type="text/javascript" charset="utf-8" src="<?php bloginfo('template_directory'); ?>script1.js"></script>
       } elseif ( is_page( ( 18 ) {
       <script type="text/javascript" charset="utf-8" src="<?php bloginfo('template_directory'); ?>/script18.js"></script>
       } endif; ?>
       ```
   
 * Where is my problem occurring and what is the fix?

Viewing 1 replies (of 1 total)

 *  [Big Bagel](https://wordpress.org/support/users/big-bagel/)
 * (@big-bagel)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/conditional-tags-if-else-question/#post-2419576)
 * If this is your exact code, then your parentheses are a bit off and you either
   need to echo your HTML `<script>` tags or break out of/into PHP. Also, if you’re
   going to use brackets, you shouldn’t use `endif;`.
 * Here’s an example that _should_ work (didn’t actually test it of course):
 *     ```
       <?php if ( is_page( 3 ) ) { ?>
           <script type="text/javascript" charset="utf-8" src="<?php bloginfo( 'template_directory' ); ?>/script1.js"></script>
       <?php } elseif ( is_page( 18 ) ) { ?>
           <script type="text/javascript" charset="utf-8" src="<?php bloginfo( 'template_directory' ); ?>/script18.js"></script>
       <?php } ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Conditional Tags if else question’ is closed to new replies.

## Tags

 * [conditional tags](https://wordpress.org/support/topic-tag/conditional-tags/)
 * [else](https://wordpress.org/support/topic-tag/else/)
 * [else if](https://wordpress.org/support/topic-tag/else-if/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [syntax error](https://wordpress.org/support/topic-tag/syntax-error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Big Bagel](https://wordpress.org/support/users/big-bagel/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/conditional-tags-if-else-question/#post-2419576)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
