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

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

You may like following Articles!

  • http://digcms.com John

    This is really helpful….