Support

Home Forums Event Espresso Premium Loading a script on a specific page

Loading a script on a specific page

Posted: December 14, 2012 at 10:00 am

Viewing 3 reply threads


spark

December 14, 2012 at 10:00 am

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?


Dean

December 17, 2012 at 2:11 am

Hi,

Why not just using the Venue shortcode? https://eventespresso.com/wiki/shortcodes-template-variables/#venue It has Google maps functionality built in.

Otherwise I would say take a look at the is_page() function http://codex.wordpress.org/Function_Reference/is_page


spark

December 17, 2012 at 7:04 am

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?


Josh

  • Support Staff

December 17, 2012 at 2:04 pm

Hi Spark,

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.

Event Espresso