Advertise on Site! You can Advertise on our site. Find out More

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

3 Flares Twitter 2 Facebook 0 Google+ 1 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 3 Flares ×

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

3 Flares Twitter 2 Facebook 0 Google+ 1 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 3 Flares ×
  • http://digcms.com John

    This is really helpful….

3 Flares Twitter 2 Facebook 0 Google+ 1 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 3 Flares ×