WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Loading scripts on a page-by-page basis (2 posts)

  1. vikkineal
    Member
    Posted 1 year ago #

    Hi there

    I'm trying to avoid loading unnecessary js files via the header, by using some PHP to load only certain scripts on certain pages.

    I seem to be having problems with my syntax however for chaining two options together... I want the following code to load if the page isn't using the template modelpages.php and if it isn't single.

    Here's what I've cobbled together, but it doesn't seem to work...

    <?php if (! is_page_template('modelPages.php') || (! is_single()) ) { ?>
    <script type="text/javascript" src="<?php echo bloginfo('template_directory');?>/scripts/jquery.easing.min.js"></script>
    <script type="text/javascript" src="<?php echo bloginfo('template_directory');?>/scripts/supersized.3.2.7.min.js"></script>
    <?php } ?>

    Any ideas?

  2. vikkineal
    Member
    Posted 1 year ago #

    <?php if ( !( is_page_template('modelPages.php') || is_archive() || is_single() ) ) { ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags