How to load the custom javascript to custom page template in wordpress

Sponsors

For many pupose and designs we use the page template in wordpress site. Some time we need to load the custom javascript to page template.

For that we can use following code.

add_action('wp_enqueue_scripts','Load_Template_Scripts_wpapi');
function Load_Template_Scripts_wpapi(){
    if ( is_page_template('custom-page.php') ) {
        wp_enqueue_script('my-script', 'path/to/script.js');
    }
}

For loading any script or any custom code you can use above action in wordpress. Above code you need to add in functions.php file. Which you can find in your wordpress theme folder.

How to load the custom javascript to custom page template in wordpress How to load the custom javascript to custom page template in wordpress

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

You may like following Articles!

One thought on “How to load the custom javascript to custom page template in wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>