Forums

[resolved] How to add jQuery script to a specify page only (5 posts)

  1. davidzupec
    Member
    Posted 8 months ago #

    Hello all, I want to load a jQuery script to one of my pages in wordpress without it loading on all the pages. When I register and enqueue the script in my functions.js file it loads up on all my pages.

    Thank you for your help : )

  2. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Enqueue the script via a function and then only add the filter to wp_head based on an is_page() conditional.

  3. davidzupec
    Member
    Posted 8 months ago #

    Hello esmi, this is my code but it's still not loading?

    <?php wp_head(); ?>
    
    	<?php if (is_page('home')) { ?>
    		<script src="<?php bloginfo('template_url'); ?>/js/load.js"></script>
    		<script src="<?php bloginfo('template_url'); ?>/js/jquery.flexslider.js"></script>
    	<?php } ?>
    
    </head>
  4. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

  5. davidzupec
    Member
    Posted 8 months ago #

    Thank you esmi this helped : )

Reply

You must log in to post.

About this Topic

Tags