WordPress.org

Support

Support » Plugins and Hacks » Events Manager » [Resolved] Accessing an Event Location Map from a Custom Post Type

[Resolved] Accessing an Event Location Map from a Custom Post Type

  • I’m using the latest version of Events Manager and would like to access the Google map that’s generated from the Events Manager location post type from another custom post type using an advanced custom field. If that’s not possible is there another way to display the maps on my site outside of Events Manager?

    http://wordpress.org/extend/plugins/events-manager/

Viewing 10 replies - 1 through 10 (of 10 total)
  • angelo_nwl

    @angelo_nwl

    NetWebLogic Support

    you can use shortcodes like [locations_map] or wordpress do_shortcode

    Shortcodes

    My apologies, here’s the scenario – my CPT called “Class Locations” has an Advanced Custom Field of the type post object which allows the user to select one of the Events Manager’s predefined locations containing the Google map. How can I display that map by placing code in my template that’s iterating through those fields to display the information on the page? I don’t want my user to have to use the html tab.

    Plugin Author Marcus

    @netweblogic

    in php it could be something like:

    $EM_Location = em_get_location(location_id);
    $EM_Location->output(‘#_LOCATIONMAP’);

    I’m sure someone with more experience could get this to work but the php I’m using throws a fatal error;

    Catchable fatal error: Object of class WP_Post could not be converted to string in /Applications/MAMP/htdocs/wp-content/plugins/advanced-custom-fields/core/api.php

    <?php
    	$EM_Location = em_get_location(the_field('event_location', $location->ID));
    	$EM_Location->output('#_LOCATIONMAP');
    ?>
    angelo_nwl

    @angelo_nwl

    NetWebLogic Support

    can I know where did you add the snippet above?

    I added it to my template. Here’s the block in question;

    <?php elseif(get_row_layout() == "location_block"): // layout: Location Block ?>
    
      <?php $location = get_sub_field('location'); ?>
      <h2 id="top"><?php echo get_the_title($location->ID); ?></h2>
      <h3><?php the_field('location_address', $location->ID); ?></h3>
      <p><?php the_field('location_details', $location->ID); ?></p>
    
            <?php
            $EM_Location = em_get_location(the_field('event_location', $location->ID));
    	$EM_Location->output('#_LOCATIONMAP');
    	?>

    caimin_nwl

    @caimin_nwl

    NetWebLogic Support

    Which template?

    I’m using this template to display a page containing a list of classes and other information pertaining to them.
    Here’s the whole shebang;
    `<?php
    /**
    * Template Name: Classes Template
    * Description: A Page Template that adds a sidebar to pages
    *
    * @package WordPress
    * @subpackage Twenty_Eleven
    * @since Twenty Eleven 1.0
    */

    get_header(); ?>

    <div id=”primary”>
    <div id=”content” role=”main”>

    <?php while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( ‘content’, ‘page’ ); ?>
    <h3>View the Pasadena, Texas Boot Camp Classes</h3>
    <?php the_field(‘general_information’); ?>

    <?php while(has_sub_field(“class_objects”)): ?>

    <?php if(get_row_layout() == “city_block”): // layout: City Block ?>

    <?php $city = get_sub_field(‘city’); ?>
    <h2 class=”location entry-title”><?php echo get_the_title($city->ID); ?></h2>

    <?php elseif(get_row_layout() == “location_block”): // layout: Location Block ?>

    <?php $location = get_sub_field(‘location’); ?>
    <h2 id=”top”><?php echo get_the_title($location->ID); ?></h2>
    <h3><?php the_field(‘location_address’, $location->ID); ?></h3>
    <h3><?php the_field(‘location_details’, $location->ID); ?></h3>
    <?php
    $EM_Location = em_get_location(the_field(‘event_location’, $location->ID));
    $EM_Location->output(‘#_LOCATIONMAP’);
    ?>

    <?php elseif(get_row_layout() == “class_block”): // layout: Class Block ?>

    <?php
    $class = get_sub_field(‘class’);
    $instructor = get_field(‘instructor’, $class->ID);
    $instructor_first_name = get_field(‘first_name’, $instructor->ID); // nested post object
    $instructor_first_name_lower = strtolower($instructor_first_name);
    ?>

    <div class=”sf-classes”>
    <table border=”0″ cellspacing=”0″ cellpadding=”3″>
    <tbody>
    <tr>
    <td style=”color: #ffffff; border-top: none;” colspan=”3″ align=”left” valign=”top” bgcolor=”#32347D”><span class=”FBCGreen”><?php echo get_the_title($class->ID); ?></span></td>
    <td style=”color: #ffffff; border-top: none; text-align: right;” colspan=”3″ align=”right” valign=”top” bgcolor=”#32347D”><span class=”FBCGreen”>Instructor: s-bio”><?php echo $instructor_first_name ?></span></td>
    </tr>
    <tr>
    <td align=”left” valign=”top” bgcolor=”#f0f0f0″ width=”80″><span class=”font_small” style=”font-weight: bold;”>MON</span></td>
    <td align=”left” valign=”top” bgcolor=”#f0f0f0″ width=”80″><span class=”font_small” style=”font-weight: bold;”>TUE</span></td>
    <td align=”left” valign=”top” bgcolor=”#f0f0f0″ width=”80″><span class=”font_small” style=”font-weight: bold;”>WED</span></td>
    <td align=”left” valign=”top” bgcolor=”#f0f0f0″ width=”80″><span class=”font_small” style=”font-weight: bold;”>THU</span></td>
    <td align=”left” valign=”top” bgcolor=”#f0f0f0″ width=”80″><span class=”font_small” style=”font-weight: bold;”>FRI</span></td>
    <td align=”left” valign=”top” bgcolor=”#f0f0f0″ width=”50″><span class=”font_small” style=”font-weight: bold;”>SAT</span></td>
    </tr>
    <tr>
    <td align=”left” valign=”top”><?php the_field(‘monday_start_time’, $class->ID); ?></td>
    <td align=”left” valign=”top”><?php the_field(‘tuesday_start_time’, $class->ID); ?></td>
    <td align=”left” valign=”top”><?php the_field(‘wednesday_start_time’, $class->ID); ?></td>
    <td align=”left” valign=”top”><?php the_field(‘thursday_start_time’, $class->ID); ?></td>
    <td align=”left” valign=”top”><?php the_field(‘friday_start_time’, $class->ID); ?></td>
    <td align=”left” valign=”top”><?php the_field(‘saturday_start_time’, $class->ID); ?></td>
    </tr>
    </tbody>
    </table>
    <div class=”icon-helpers group”>
    <div class=”hover-container-small”>
    register<span class=”hover” style=”opacity: 0;”></span>
    </div>
    <p>CalendarMaps-bio”>Instructor Bio</p>
    </div>
    </div>

    <?php endif; ?>

    <?php endwhile; ?>

    <?php comments_template( ”, true ); ?>

    <?php endwhile; // end of the loop. ?>

    </div><!– #content –>
    </div><!– #primary –>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>’

    Plugin Author Marcus

    @netweblogic

    $EM_Location = em_get_location(get_the_ID(),'post_id');
    $EM_Location->output('#_LOCATIONMAP');

    that should work, if you still have issues you’ll probably need to hire a developer to help you.

    Thank you. I appreciate your efforts and this plugin.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Accessing an Event Location Map from a Custom Post Type’ is closed to new replies.
Skip to toolbar