Event Organiser
[resolved] How do I add a map to the 'single-event' template? (8 posts)

  1. Danny
    Posted 3 years ago #

    I want to add a map of the location/venue to the single-event.php template.

    How can I go about this?

    Thank you!


  2. Stephen Harris
    Posted 3 years ago #

    You can use eo_get_venue_map(). If used outside loop you need to pass the venue ID (as an integer) or the slug (as a string). Inside the loop, you can pass nothing and it'll use the current event's venue.

    You can see in the source here: https://github.com/stephenh1988/Event-Organiser/blob/1.5.7/includes/event-organiser-venue-functions.php#L548

    The second, optional argument, is an array. Currently it supports the following keys (and their default values:)

    'zoom' => 15,
        'width' => '100%',
        'height' => '200px',
        'class' => '',//Apply a class to the map container
  3. Danny
    Posted 3 years ago #

    Ok. I understand the 'inside loop' and 'outside loop' part..
    I put line 548-551 from your link in my template inside <?php ... ?> tags..

    Didn't work. Am I missing something?

    (Im kinda new to PHP if you haven't noticed..lol)

  4. Danny
    Posted 3 years ago #

    i added

    <div class="entry-map"><?php eo_get_venue_map(); ?></div>

    didn't work..

  5. Stephen Harris
    Posted 3 years ago #

    Thats the correct usage, if used inside the loop. What exactly doesn't work? Does the map not render, or does it just show the sea? Does the venue map shorcode work ok?

    You don't want to be copying the source in, just using the function as you have in your last post should work

    Does it work if you pass in a venue slug as the first argument?

  6. Danny
    Posted 3 years ago #

    the map just doesn't show up.
    checked the source code and it just shows the div tags.

  7. Stephen Harris
    Posted 3 years ago #

    Sorry, my mistake!

    It should be `

    <div class="entry-map"><?php echo eo_get_venue_map(); ?></div>

    Apologies for any inconvenience.

  8. Danny
    Posted 3 years ago #

    works now! thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Event Organiser
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.