I need to add some scrips for Google Maps only in my contact page and I do not want to populate it on all pages. I am not willing to create a custom header as well so I was thinking is there any way to populate the js file only on contact page?
currently I am using this code to add javascript to theme
//Load Scripts
function load_scripts(){
wp_deregister_script('jquery'); // De-register Existing jquery
wp_enqueue_script('jquery', 'http://code.jquery.com/jquery.js', '', '', true);
wp_enqueue_script('bootstrap-jquery', get_template_directory_uri().'/assets/js/bootstrap.js', '', '', true);
}
but as I said I have another file called googlemap.js can you please let me know if I can add it to ONLY contact page from this code? the other Point is WordPress is adding this code at the end of body (before tag) which honestly I do not know how and why! but in my specific case I need to add the code into ! can you please let me know how I can do this
Thanks
Use conditional
is_page()
for loading script on specific page.Here Is The Modified Version of Your Function:
Here is some tricks for you
Note:
In your functions.php file