I added a Google Maps display via their API and the gMap plugin to my events’ pages, that is, in registration_page_display.php. I add the scripts in registration_page.php like so:
function addGoogleMapScripts(){
wp_enqueue_script('google-maps','http://maps.google.com/maps?file=api&v=2&key=','jquery');
wp_enqueue_script('gMap',JSDIR.'/jquery.gmap-1.1.0-min.js','jquery','1.1.0');
}
add_action('wp_head','addGoogleMapScripts');
The problem is that these things are being loaded on ANY page of the website, whether they’re related to Event Espresso or not. Where/how can I add these scripts so that they only load on the event information page?
Ah, it’s funny I searched through the support section and I did not see that shortcode. I’ll try that out.
While we’re on the subject, I tried using is_page() but I couldn’t figure out what the correct parameter should be. I tried the slug that appears on a single event page, is_page(‘event-information’), and the slug of my event calendar page, is_page(‘event-calendar’), but neither worked. What is the right parameter for a single event page?
You could try creating a single event page by using the [SINGLEEVENT] shortcode on the page, and use the slug or the page ID for that page. A single event page that gets dynamically generated from the [ESPRESSO_EVENTS] shortcode will share the same slug and page ID will all the other events.
Viewing 3 reply threads
The support post ‘Loading a script on a specific page’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.