You can use is_page_template
to check if you template is being used and load your scripts based on that ex:
Add this code to your functions.php file:
1 2 3 4 5 6 7 | add_action('wp_enqueue_scripts','Load_Template_Scripts_wpa83855'); function Load_Template_Scripts_wpa83855(){ if ( is_page_template('custom-page.php') ) { wp_enqueue_script('my-script', 'path/to/script.js'); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.