However these are loading on each page causing errors.
Now, I have decided to conditionally enqueue each script like so;
add_action('wp_enqueue_scripts', 'add_script_function');
function add_script_function() {
if (is_page(2393)) {
wp_enqueue_script('SERVICESGMAPI', 'https://maps.googleapis.com/maps/api/js?key=KEYHIDDEN&libraries=places&language=en-GB');
);
}
}
add_action('wp_enqueue_scripts', 'add_script_function');
function add_script_function() {
if (is_page(vacancies)) {
wp_enqueue_script('VACANCIESGMAPI', 'https://maps.googleapis.com/maps/api/js?key=KEYHIDDEN&libraries=places&language=en-GB');
);
}
}
add_action('wp_enqueue_scripts', 'add_script_function');
function add_script_function() {
if (is_page(events)) {
wp_enqueue_script('EVENTSGMAPI', 'https://maps.googleapis.com/maps/api/js?key=KEYHIDDEN&libraries=places&language=en-GB');
);
}
}
BUT, with the events page, each event is permalinked like so;
So the code above (3rd part) will load the script on mydomain.tld/events, how can I set it to work on the event/* pages?
Also, the scripts are being loaded via the plugins, if I change that via editting the plugins, changes will revert on updates. Any advice?
]]>Please continue there.
]]>