• 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)
  • 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.