Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5921
    piotrly
    Participant

    How to display location details (address, city) and organizer (contact name, phone) directly on event page not as a link to seperate page?

    #5954
    Bartosz
    Keymaster

    There are multiple ways, using hooks, template files or functions.

    I suggest focusing on em_display_event_locations function located in template-functions.php. You can copy it to your theme and modify to adjust your needs (it will be used instead of the default one).

    You may also replace the em_display_event_locations hook, that looks like this in template files:

    <?php
    /**
     * em_after_single_event_title hook
     * 
     * @hooked em_display_single_event_meta - 10
     * @hooked em_display_event_locations - 20
     * @hooked em_display_event_organizers - 30
     * @hooked em_display_google_map - 40
     * @hooked em_display_event_tickets - 50
     */
    do_action ('em_after_single_event_title');
    ?>

    Then hook into em_after_single_event_title and add your own display.

    #5965
    piotrly
    Participant

    Thanks for help. I’ve used this code in content-single-event.php:

    <?php
    $post_id = (int)(empty($post_id) ? get_the_ID() : $post_id);
    if(empty($post_id))
    	return false;
    $locations = em_get_locations_for($post_id);
    if(empty($locations) || is_wp_error($locations))
    	return false;
    ?>
    <?php $output = '<div class="entry-meta"><span class="term-list event-location cat-links">' . __('<strong>Location: </strong>', 'events-maker');
       	foreach ($locations as $term) :
    		$output .= $term->name . '</span></div>'; ?>
    	<?php $location_details = $term->location_meta;
    	if ($location_details) :
    		$output .= '<div class="entry-meta"><span class="term-list event-address cat-links">' . __('<strong>Address: </strong>', 'events-maker');
    		$output .= !empty($location_details['address']) ? $location_details['address'] . ', ' : '';
    		$output .= !empty($location_details['zip']) ? $location_details['zip'] . ' ' : '';
    		$output .= !empty($location_details['city']) ? $location_details['city'] . ' ' : '';
    	endif;
    	$output .= '</span></div>';
    	endforeach; ?>
    <?php echo $output; ?>
    		
    <?php
    $post_id = (int)(empty($post_id) ? get_the_ID() : $post_id);
    if(empty($post_id))
    	return false;
    $organizers = em_get_organizers_for($post_id);
    if(empty($organizers) || is_wp_error($organizers))
    	return false;
    ?>
    <?php $output = '<div class="entry-meta"><span class="term-list event-organizer cat-links">' . __('<strong>Organizer: </strong>', 'events-maker');
    	foreach ($organizers as $term) :
    		$output .= $term->name . '</span></div>'; ?>
    	<?php $organizer_details = $term->organizer_meta;
    	if ($organizer_details) :
    		$output .= '<div class="entry-meta"><span class="term-list event-contact cat-links">' . __('<strong>Contact: </strong>', 'events-maker');
    		$output .= !empty($organizer_details['contact_name']) ? $organizer_details['contact_name'] . ', ' : '';
    		$output .= !empty($organizer_details['phone']) ? __('phone: ', 'events-maker') . $organizer_details['phone'] . ', ' : '';
    		$output .= !empty($organizer_details['email']) ? __('e-mail: ', 'events-maker') . '<a href="mailto:' . $organizer_details['email'] . '">' . $organizer_details['email'] . '</a> ' : '';
    		$output .= !empty($organizer_details['website']) ? $organizer_details['website'] . ' ' : '';
    	endif;
    	$output .= '</span></div>';
    	endforeach; ?>
    <?php echo $output; ?>
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.