WP Event Manager Shortcodes

Below, you’ll find a detailed guide on how to add the WP Event Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP Event Manager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the WP Event Manager Plugin and the shortcodes it provides:

Plugin Icon
WP Event Manager – Events Calendar, Registrations, Sell Tickets with WooCommerce

"WP Event Manager is a robust WordPress plugin that transforms your site into a fully functional event management platform. It offers an events calendar, registration capabilities, and integrates with WooCommerce for ticket sales."

★★★★✩ (258) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [submit_event_form]
  • [event_dashboard]
  • [events]
  • [event]
  • [event_summary]
  • [past_events]
  • [event_register]
  • [upcoming_events]
  • [submit_organizer_form]
  • [organizer_dashboard]
  • [event_organizers]
  • [event_organizer]
  • [single_event_organizer]
  • [submit_venue_form]
  • [venue_dashboard]
  • [event_venues]
  • [event_venue]
  • [single_event_venue]

WP Event Manager [submit_event_form] Shortcode

The WP Event Manager shortcode, ‘submit_event_form’, is designed to display an event submission form on your website. This shortcode calls the ‘submit_event_form’ function, which retrieves the ‘submit-event’ form from the Event Manager plugin. It allows users to submit their own events, making your site interactive and user-friendly.

Shortcode: [submit_event_form]

Examples and Usage

Basic example – Enables the user to submit an event form without any specific parameters.

[submit_event_form]

PHP Function Code

In case you have difficulties debugging what causing issues with [submit_event_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('submit_event_form', array($this, 'submit_event_form'));

Shortcode PHP function:

function submit_event_form($atts = array()){
		return $GLOBALS['event_manager']->forms->get_form('submit-event', $atts);
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_dashboard] Shortcode

The WP Event Manager shortcode ‘event_dashboard’ is responsible for displaying the user’s event dashboard. It checks if the user is logged in and retrieves the event data based on specified parameters. The ‘event_dashboard’ shortcode handles event listings, sorting, and pagination. It also manages search functionality and filters the events based on location, start and end dates. Shortcode: [event_dashboard]

Shortcode: [event_dashboard]

Examples and Usage

Basic example – Displaying the event dashboard with the default number of posts per page

[event_dashboard]

PHP Function Code

In case you have difficulties debugging what causing issues with [event_dashboard] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_dashboard', array($this, 'event_dashboard'));

Shortcode PHP function:

function event_dashboard($atts){

		global $wpdb, $event_manager_keyword;

		if(!is_user_logged_in()) {
			ob_start();
			get_event_manager_template('event-dashboard-login.php');
			return ob_get_clean();
		}

		extract(shortcode_atts(array(
			'posts_per_page' => '10',
		), $atts));

		wp_enqueue_script('wp-event-manager-event-dashboard');

		ob_start();

		$search_order_by = 	isset($_GET['search_order_by']) ? sanitize_text_field($_GET['search_order_by']) : '';

		if(isset($search_order_by) && !empty($search_order_by)) {
			$search_order_by = explode('|', $search_order_by);
			$orderby = $search_order_by[0];
			$order = $search_order_by[1];
		} else {
			$orderby = 'date';
			$order = 'desc';
		}

		// ....If not show the event dashboard
		$args = apply_filters('event_manager_get_dashboard_events_args', array(
			'post_type'           => 'event_listing',
			'post_status'         => array('publish', 'expired', 'pending'),
			'ignore_sticky_posts' => 1,
			'posts_per_page'      => $posts_per_page,
			'offset'              => (max(1, get_query_var('paged')) - 1) * $posts_per_page,
			'orderby'             => $orderby,
			'order'               => $order,
			'author'              => get_current_user_id()
		));

		$event_manager_keyword = isset($_GET['search_keywords']) ? sanitize_text_field($_GET['search_keywords']) : '';
		if(!empty($event_manager_keyword) && strlen($event_manager_keyword) >= apply_filters('event_manager_get_listings_keyword_length_threshold', 2)) {
			$args['s'] = $event_manager_keyword;
			add_filter('posts_search', 'get_event_listings_keyword_search');
		}

		if(isset($args['orderby']) && !empty($args['orderby'])) {
			if($args['orderby'] == 'event_location') {
				$args['meta_query'] = array(
					'relation' => 'AND',
					'event_location_type_clause' => array(
						'key'     => '_event_online',
						'compare' => 'EXISTS',
					),
					'event_location_clause' => array(
						'key'     => '_event_location',
						'compare' => 'EXISTS',
					), 
				);
				$args['orderby'] = array(
					'event_location_type_clause' => ($search_order_by[1]==='desc') ? 'asc' : 'desc',
					'event_location_clause' => $search_order_by[1],
				);
				
			} elseif($args['orderby'] == 'event_start_date') {
				$args['meta_key'] = '_event_start_date';
				$args['orderby'] = 'meta_value';
				$args['meta_type'] = 'DATETIME';
			}
			elseif($args['orderby'] == 'event_end_date') {
				$args['meta_key'] = '_event_end_date';
				$args['orderby'] = 'meta_value';
				$args['meta_type'] = 'DATETIME';
			}
		}

		$events = new WP_Query($args);

		echo  wp_kses($this->event_dashboard_message, wp_kses_allowed_html($this->event_dashboard_message));
		//display organiser delete message #905
		echo    wp_kses($this->organizer_dashboard_message, wp_kses_allowed_html($this->organizer_dashboard_message));
		//display venue delete message #905
		echo wp_kses($this->venue_dashboard_message, wp_kses_allowed_html($this->venue_dashboard_message));

		$event_dashboard_columns = apply_filters('event_manager_event_dashboard_columns', array(
			'event_title' => __('Title', 'wp-event-manager'),
			'event_location' => __('Location', 'wp-event-manager'),
			'event_start_date' => __('Start Date', 'wp-event-manager'),
			'event_end_date' => __('End Date', 'wp-event-manager'),
			'view_count' => __('Viewed', 'wp-event-manager'),
			'event_action' => __('Action', 'wp-event-manager'),
		));

		$event_dashboard_columns = apply_filters('event_manager_event_dashboard_columns', array(
			'view_count' => __('Viewed', 'wp-event-manager'),
		));

		get_event_manager_template('event-dashboard.php', array('events' => $events->query($args), 'max_num_pages' => $events->max_num_pages, 'event_dashboard_columns' => $event_dashboard_columns, 'atts' => $atts));

		remove_filter('posts_search', 'get_event_listings_keyword_search');

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [events] Shortcode

The WP Event Manager shortcode is a powerful tool that allows users to display event listings on their WordPress site. This shortcode extracts attributes such as the number of events per page, order, filters, categories, and more. Furthermore, it allows customization of event display based on categories, types, ticket prices, and also supports pagination. The shortcode is versatile, providing control over what events are shown and how they are sorted and filtered.

Shortcode: [events]

Parameters

Here is a list of all possible events shortcode parameters and attributes:

  • per_page – Determines the number of events displayed per page.
  • orderby – Sets the sorting parameter for the events.
  • order – Defines the sorting order, can be ascending (ASC) or descending (DESC).
  • show_filters – Controls whether the event filters are displayed.
  • filter_style – Sets the style of the event filters.
  • show_categories – Controls the display of event categories.
  • show_event_types – Controls the display of event types.
  • show_ticket_prices – Controls the display of ticket prices.
  • show_category_multiselect – Enables or disables multiple category selection.
  • show_event_type_multiselect – Enables or disables multiple event type selection.
  • show_pagination – Controls the display of pagination.
  • show_more – Controls the display of the “Show More” button.
  • categories – Filters events by categories.
  • event_types – Filters events by event types.
  • ticket_prices – Filters events by ticket prices.
  • featured – Filters events by featured status.
  • cancelled – Filters events by cancellation status.
  • location – Filters events by location.
  • keywords – Filters events by keywords.
  • selected_datetime – Filters events by selected date and time.
  • selected_category – Filters events by selected category.
  • selected_event_type – Filters events by selected event type.
  • selected_ticket_price – Filters events by selected ticket price.
  • layout_type – Sets the layout type for the events.
  • event_online – Filters events by online status.
  • title – Sets the title of the event listings.

Examples and Usage

Basic example – Display events with default settings

[events]

Advanced examples

Display events with a limit of 5 per page and order them by event start date in descending order

[events per_page=5 orderby='meta_value' order='DESC']

Display events with filters, specific categories and event types

[events show_filters=true categories='conference,workshop' event_types='online,physical']

Display events with a specific location and keyword in the title

[events location='New York' keywords='technology']

Display only featured or cancelled events

[events featured=true]
[events cancelled=true]

Display events with a specific ticket price range

[events ticket_prices='20,50']

Display events that are happening online

[events event_online=true]

PHP Function Code

In case you have difficulties debugging what causing issues with [events] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('events', array($this, 'output_events'));

Shortcode PHP function:

function output_events($atts){
		ob_start();

		extract($atts = shortcode_atts(apply_filters('event_manager_output_events_defaults', array(
			'per_page'                  => get_option('event_manager_per_page'),
			'orderby'                   => 'meta_value', // meta_value
			'order'                     => 'ASC',
			
			// Filters + cats
			'show_filters'              => true,
			'filter_style'              => '',
			'show_categories'           => true,
			'show_event_types'          => true,
			'show_ticket_prices'        => true,
			'show_category_multiselect' => get_option('event_manager_enable_default_category_multiselect', false),
			'show_event_type_multiselect' => get_option('event_manager_enable_default_event_type_multiselect', false),
			'show_pagination'           => false,
			'show_more'                 => true,
			
			// Limit what events are shown based on category and type
			'categories'                => '',
			'event_types'               => '',
			'ticket_prices'             => '',
			'featured'                  => null, // True to show only featured, false to hide featured, leave null to show both.
			'cancelled'                 => null, // True to show only cancelled, false to hide cancelled, leave null to show both/use the settings.

			// Default values for filters
			'location'                  => '',
			'keywords'                  => '',
			'selected_datetime'         => '',
			'selected_category'         => '',
			'selected_event_type'       => '',
			'selected_ticket_price'     => '',
			'layout_type'      			=> 'all',
			'event_online'      		=> '',
			'title'                     => __('Events', 'wp-event-manager'),
		)), $atts));

		//Categories
		if(!get_option('event_manager_enable_categories')) {
			$show_categories = false;
		}

		//Event types
		if(!get_option('event_manager_enable_event_types')) {
			$show_event_types = false;
		}

		//Event ticket prices		
		if(!get_option('event_manager_enable_event_ticket_prices_filter')) {
			$show_ticket_prices = false;
		}
		// String and bool handling
		$show_filters              = $this->string_to_bool($show_filters);
		$show_categories           = $this->string_to_bool($show_categories);
		$show_event_types          = $this->string_to_bool($show_event_types);
		$show_ticket_prices        = $this->string_to_bool($show_ticket_prices);
		$show_category_multiselect = $this->string_to_bool($show_category_multiselect);
		$show_event_type_multiselect = $this->string_to_bool($show_event_type_multiselect);
		$show_more                 = $this->string_to_bool($show_more);
		$show_pagination           = $this->string_to_bool($show_pagination);

		//order by meta value and it will take default sort order by start date of event
		if(is_null($orderby) ||  empty($orderby)) {
			$orderby  = 'meta_value';
		}

		if(!is_null($featured)) {
			$featured = (is_bool($featured) && $featured) || in_array($featured, array('1', 'true', 'yes')) ? true : false;
		}

		if(!is_null($cancelled)) {
			$cancelled = (is_bool($cancelled) && $cancelled) || in_array($cancelled, array('1', 'true', 'yes')) ? true : false;
		}

		if(!empty($selected_datetime)){
			if(is_array($selected_datetime)){
			}
		}
		//set value for the event datetimes
		$datetimes = WP_Event_Manager_Filters::get_datetimes_filter();

		//Set value for the ticket prices		
		// $ticket_prices	=	WP_Event_Manager_Filters::get_ticket_prices_filter();
		
		// Array handling
		$datetimes            = is_array($datetimes) ? $datetimes : array_filter(array_map('trim', explode(',', $datetimes)));
		$categories           = is_array($categories) ? $categories : array_filter(array_map('trim', explode(',', $categories)));
		$event_types          = is_array($event_types) ? $event_types : array_filter(array_map('trim', explode(',', $event_types)));
		if(!empty($ticket_prices)){
			$ticket_prices        = is_array($ticket_prices) ? $ticket_prices : array_filter(array_map('trim', explode(',', $ticket_prices)));
		}
		// Get keywords, location, datetime, category, event type and ticket price from query string if set
		if(!empty($_GET['search_keywords'])) {
			$keywords = sanitize_text_field($_GET['search_keywords']);
		}

		if(!empty($_GET['search_location'])) {
			$location = sanitize_text_field($_GET['search_location']);
		}

		if(!empty($_GET['search_datetime'])) {
			$selected_datetime = sanitize_text_field($_GET['search_datetime']);
		}

		if(!empty($_GET['search_category'])) {
			$selected_category = sanitize_text_field($_GET['search_category']);
		}

		if(!empty($_GET['search_event_type'])) {
			$selected_event_type = sanitize_text_field($_GET['search_event_type']);
		}

		if(!empty($_GET['search_ticket_price'])) {
			$selected_ticket_price = sanitize_text_field($_GET['search_ticket_price']);
		}
		if($show_filters) {
			get_event_manager_template('event-filters.php', array(
				'per_page' => $per_page,
				'orderby' => $orderby,
				'order' => $order,
				'datetimes' => $datetimes,
				'selected_datetime' => $selected_datetime,
				'show_categories' => $show_categories,
				'show_category_multiselect' => $show_category_multiselect,
				'categories' => $categories,
				'selected_category' => !empty($selected_category) ? explode(',', $selected_category) : '',
				'show_event_types' => $show_event_types,
				'show_event_type_multiselect' => $show_event_type_multiselect,
				'event_types' => $event_types,
				'selected_event_type' => !empty($selected_event_type) ? explode(',', $selected_event_type) : '',
				'show_ticket_prices' => $show_ticket_prices,
				'ticket_prices' => $ticket_prices,
				'selected_ticket_price' => $selected_ticket_price,
				'atts' => $atts,
				'location' => $location,
				'keywords' => $keywords,
				'event_online' => $event_online,
			));

			get_event_manager_template('event-listings-start.php', array('layout_type' => $layout_type, 'title' => $title));
			get_event_manager_template('event-listings-end.php', array('show_filters' => $show_filters, 'show_more' => $show_more, 'show_pagination' => $show_pagination));

		} else {
			$arr_selected_datetime = [];
			if(!empty($selected_datetime)) {
				$selected_datetime = explode(',', $selected_datetime);

				$start_date = esc_attr(strip_tags($selected_datetime[0]));
				$end_date = esc_attr(strip_tags($selected_datetime[1]));

				//get date and time setting defined in admin panel Event listing -> Settings -> Date & Time formatting
				$datepicker_date_format 	= WP_Event_Manager_Date_Time::get_datepicker_format();

				//covert datepicker format  into php date() function date format
				$php_date_format 		= WP_Event_Manager_Date_Time::get_view_date_format_from_datepicker_date_format($datepicker_date_format);

				if($start_date == 'today') {
					$start_date = date($php_date_format);
				} else if($start_date == 'tomorrow') {
					$start_date = date($php_date_format, strtotime('+1 day'));
				}

				$arr_selected_datetime['start'] = WP_Event_Manager_Date_Time::date_parse_from_format($php_date_format, $start_date);
				$arr_selected_datetime['end'] = WP_Event_Manager_Date_Time::date_parse_from_format($php_date_format, $end_date);

				$arr_selected_datetime['start'] 	= date_i18n($php_date_format, strtotime($arr_selected_datetime['start']));
				$arr_selected_datetime['end'] 	= date_i18n($php_date_format, strtotime($arr_selected_datetime['end']));

				$selected_datetime = json_encode($arr_selected_datetime);
			}
			
			$events = get_event_listings(apply_filters('event_manager_output_events_args', array(
				'search_location'   => $location,
				'search_keywords'   => $keywords,
				'search_datetimes'  => array($selected_datetime),
				'search_categories' => !empty($categories) ? $categories : '',
				'search_event_types'	=> !empty($event_types) ? $event_types : '',
				'search_ticket_prices'  => !empty($ticket_prices) ? $ticket_prices : '',
				'orderby'           => $orderby,
				'order'             => $order,
				'posts_per_page'    => $per_page,
				'featured'          => $featured,
				'cancelled'         => $cancelled,
				'event_online'    	=> $event_online,
			)));
			if($events->have_posts()) :

				wp_enqueue_script('wp-event-manager-ajax-filters');
				get_event_manager_template('event-listings-start.php', array('layout_type' => $layout_type, 'title' => $title));
				while ($events->have_posts()) : $events->the_post();
					get_event_manager_template_part('content', 'event_listing');
				endwhile; 
				get_event_manager_template('event-listings-end.php', array('show_pagination' => $show_pagination, 'show_more' => $show_more, 'per_page' => $per_page, 'events' => $events, 'show_filters' => $show_filters));?>
			<?php else :
				$default_events = get_posts(array(
					'numberposts' => -1,
					'post_type'   => 'event_listing',
					'post_status'   => 'publish'
				));
				if(count($default_events) == 0): ?>
					<div class="no_event_listings_found wpem-alert wpem-alert-danger wpem-mb-0"><?php _e('There are currently no events.', 'wp-event-manager'); ?></div>
				<?php else:
					 do_action('event_manager_output_events_no_results');
				endif;
			endif;
			wp_reset_postdata();
		}

		$data_attributes_string = '';

		$data_attributes        = array(
			'location'        => $location,
			'keywords'        => $keywords,
			'show_filters'    => $show_filters ? 'true' : 'false',
			'show_pagination' => $show_pagination ? 'true' : 'false',
			'per_page'        => $per_page,
			'orderby'         => $orderby,
			'order'           => $order,
			'datetimes'       => $selected_datetime,
			'categories'      => !empty($categories) ? implode(',', $categories) : '',
			'event_types'     => !empty($event_types) ? implode(',', $event_types) : '',
			'ticket_prices'   => !empty($ticket_prices) ? implode(',', $ticket_prices) : '',
			'event_online'    => $event_online,
		);

		if(!is_null($featured)) {
			$data_attributes['featured'] = $featured ? 'true' : 'false';
		}

		if(!is_null($cancelled)) {
			$data_attributes['cancelled']   = $cancelled ? 'true' : 'false';
		}

		foreach ($data_attributes as $key => $value) {
			$data_attributes_string .= 'data-' . esc_attr($key) . '="' . esc_attr($value) . '" ';
		}

		$event_listings_output = apply_filters('event_manager_event_listings_output', ob_get_clean());
		return '<div class="event_listings" ' . $data_attributes_string . '>' . $event_listings_output . '</div>';
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event] Shortcode

The WP Event Manager shortcode ‘event’ dynamically displays specific event details. It pulls data based on the ‘id’ attribute, allowing for customization. The PHP code checks for the event’s status, whether published or expired. It then initiates a new WP Query to fetch the event details and displays them using the ‘content-single’ template part. This shortcode is wrapped within a ‘single_event_listing’ class, enabling easy styling.

Shortcode: [event]

Parameters

Here is a list of all possible event shortcode parameters and attributes:

  • id – Specifies the unique ID of the event

Examples and Usage

Basic example – Display an event by its unique ID using the ‘event’ shortcode.

[event id=123 /]

Advanced examples

Display an event by its unique ID and override the default post status to include expired events. This is useful when you want to showcase past events on your website.

[event id=123 post_status='publish, expired' /]

Display an event by its unique ID and override the default post type to include other types of posts. This is useful when you have custom post types related to your events.

[event id=123 post_type='event_listing, custom_post_type' /]

Please note that the advanced examples require modifications in the shortcode function to accept additional parameters. Always handle such modifications with care and ensure they do not conflict with other parts of your website.

PHP Function Code

In case you have difficulties debugging what causing issues with [event] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event', array($this, 'output_event'));

Shortcode PHP function:

function output_event($atts)	{
		extract(shortcode_atts(array(
			'id' => '',
		), $atts));

		if(!$id)
			return;

		if('' === get_option('event_manager_hide_expired_content', 1)) {
			$post_status = array('publish', 'expired');
		} else {
			$post_status = 'publish';
		}

		ob_start();

		$args = array(
			'post_type'   => 'event_listing',
			'post_status' => $post_status,
			'p'           => $id
		);

		$events = new WP_Query($args);
		if($events->have_posts()) :
			while ($events->have_posts()) : $events->the_post(); ?>
				<div class="clearfix" />
				<?php get_event_manager_template_part('content-single', 'event_listing'); 
			endwhile;
		endif;
		wp_reset_postdata();
		return '<div class="event_shortcode single_event_listing">' . ob_get_clean() . '</div>';
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_summary] Shortcode

The WP Event Manager shortcode ‘event_summary’ displays a summary of event listings. It allows customization of display parameters such as alignment, width, and number of events. The PHP code extracts attributes from the shortcode, sets query parameters, and outputs the event summary. It also handles cases where no events are found.

Shortcode: [event_summary]

Parameters

Here is a list of all possible event_summary shortcode parameters and attributes:

  • id – Specifies the unique ID of the event.
  • width – Sets the width of the event summary box.
  • align – Determines the alignment of the event summary box.
  • featured – Controls the display of featured events.
  • limit – Limits the number of event summaries displayed.

Examples and Usage

Basic example – The following shortcode is a simple usage of the ‘event_summary’ shortcode. It will display one random event summary from the published events.

[event_summary limit=1 /]

Advanced examples

Displaying a specific event summary by referencing the event’s ID. This will display the event summary of the event with the specified ID.

[event_summary id=5 /]

Displaying a specific number of featured event summaries. This will display the summaries of 3 featured events in a random order.

[event_summary limit=3 featured=true /]

Displaying event summaries with a specific width and alignment. This will display the summary of one random event with a width of 300px and aligned to the right.

[event_summary width="300px" align="right" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [event_summary] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_summary', array($this, 'output_event_summary'));

Shortcode PHP function:

function output_event_summary($atts)	{
		extract(shortcode_atts(array(
			'id'       => '',
			'width'    => '250px',
			'align'    => 'left',
			'featured' => null, // True to show only featured, false to hide featured, leave null to show both (when leaving out id)
			'limit'    => 1

		), $atts));

		ob_start();

		$args = array(
			'post_type'   => 'event_listing',
			'post_status' => 'publish'
		);

		if(!$id) {
			$args['posts_per_page'] = $limit;
			$args['orderby']        = 'rand';
			if(!is_null($featured)) {
				$args['meta_query'] = array(array(
					'key'     => '_featured',
					'value'   => '1',
					'compare' => ($featured == "true") ? '=' : '!='

				));
			}
		} else {
			$args['p'] = absint($id);
		}

		$events = new WP_Query($args);
		if($events->have_posts()) { 
			while ($events->have_posts()) : $events->the_post();
				echo wp_kses_post('<div class="event_summary_shortcode align' . esc_attr($align) . '" style="width: ' . esc_attr($width) . '">');
				get_event_manager_template_part('content-summary', 'event_listing');
				echo wp_kses_post('</div>');
			endwhile;
		}else{
			echo '<div class="entry-content"><div class="wpem-venue-connter"><div class="wpem-alert wpem-alert-info">';
            printf(__('There are no events.','wp-event-manager'));    
			echo '</div></div></div>';
		}
		wp_reset_postdata();
		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [past_events] Shortcode

The WP-Event-Manager’s ‘past_events’ shortcode is designed to display a list of past events. It retrieves expired events from the database and presents them in a user-friendly format. This shortcode has several customizable attributes such as ‘per_page’, ‘order’, ‘orderby’, ‘location’, ‘keywords’, ‘selected_datetime’, ‘selected_categories’, and ‘selected_event_types’. It also supports pagination. The ‘past_events’ shortcode is an excellent tool for websites that host events and need an efficient way to manage and display past ones.

Shortcode: [past_events]

Parameters

Here is a list of all possible past_events shortcode parameters and attributes:

  • show_pagination – Determines if pagination should be displayed.
  • per_page – Sets the number of events to display per page.
  • order – Specifies the order of the events, ascending or descending.
  • orderby – Defines the parameter to order the events by.
  • location – Filters the events by their location.
  • keywords – Filters events based on specific keywords.
  • selected_datetime – Filters events based on selected date and time.
  • selected_categories – Filters events based on selected categories.
  • selected_event_types – Filters events based on selected event types.
  • layout_type – Defines the layout style for the events.
  • title – Sets the title for the events section.

Examples and Usage

Basic example – In this example, the shortcode is used to display past events without any additional parameters. By default, this will show the events in descending order by their start date.

[past_events /]

Advanced examples

Displaying past events with specific parameters. In this example, the shortcode is used to display past events, with the number of events per page set to 5, ordered in ascending order, and sorted by the event start date.

[past_events per_page="5" order="ASC" orderby="event_start_date" /]

Using the shortcode to display past events from specific categories and event types. The events will be filtered based on the provided categories and event types.

[past_events selected_categories="music,sports" selected_event_types="concert,match" /]

Displaying past events based on location and keywords. In this example, the shortcode is used to display past events that took place in ‘New York’ and have ‘music’ in their details.

[past_events location="New York" keywords="music" /]

Using the shortcode to display past events from a specific date. The events will be filtered based on the provided date.

[past_events selected_datetime="2022-05-01" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [past_events] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('past_events', array($this, 'output_past_events'));

Shortcode PHP function:

function output_past_events($atts){
		ob_start();

		extract(shortcode_atts(array(
			'show_pagination'      => true,
			'per_page'             => isset($atts['per_page']) ? $atts['per_page'] : get_option('event_manager_per_page'),
			'order'                => isset($atts['order']) ? $atts['order'] :  'DESC',
			'orderby'              => isset($atts['orderby']) ? $atts['orderby'] : 'event_start_date', // meta_value
			'location'             => '',
			'keywords'             => '',
			'selected_datetime'    => '',
			'selected_categories'  =>  isset($atts['selected_categories']) ? $atts['selected_categories'] :  '',
			'selected_event_types' => isset($atts['selected_event_types']) ? $atts['selected_event_types'] :  '',
			'layout_type'      	   => 'all',
			'title'                => __('Past Events', 'wp-event-manager'),
		), $atts));

		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

		$args_past = array(
			'post_type'  	=> 'event_listing',
			'post_status'	=> array('expired'),
			'posts_per_page' => $per_page,
			'paged'			=> $paged,
			'order'			=> $order,
			'orderby'		=> $orderby,
		);
	
		if(!empty($keywords)) {
			$args_past['s'] = $keywords;
		}

		if(!empty($selected_categories)) {
			$categories = explode(',', sanitize_text_field($selected_categories));
			$args_past['tax_query'][] = [
				'taxonomy'	=> 'event_listing_category',
				'field'   	=> 'slug',
				'terms'   	=> $categories,
			];
		}
		
		if(!empty($selected_event_types)) {
			$event_types = explode(',', sanitize_text_field($selected_event_types));
			$args_past['tax_query'][] = [
				'taxonomy'	=> 'event_listing_type',
				'field'   	=> 'slug',
				'terms'   	=> $event_types,
			];
		}

		if(!empty($selected_datetime)) {
			$datetimes = explode(',', $selected_datetime);
			$today_date = array_search('today', $datetimes);
			$yesterday_date = array_search('yesterday', $datetimes);
			$tomorrow_date = array_search('tomorrow', $datetimes);
			if($today_date != false) {
				$datetimes[$today_date] = date('Y-m-d');
			}
			if($yesterday_date != false) {
				$datetimes[$yesterday_date] = date('Y-m-d', strtotime('-1 day'));
			}
			if($tomorrow_date != false) {
				$datetimes[$tomorrow_date] = date('Y-m-d', strtotime('+1 day'));
			}
			$args_past['meta_query'][] = [
				'key' => '_event_start_date',
				'value'   => $datetimes,
				'compare' => 'BETWEEN',
				'type'    => 'date'
			];
		}

		if(!empty($location)) {
			$args_past['meta_query'][] = [
				'key' 		=> '_event_location',
				'value'  	=> $location,
				'compare'	=> 'LIKE'
			];
		}

		if('event_start_date' === $args_past['orderby']) {
			$args_past['orderby'] = 'meta_value';
			$args_past['meta_key'] = '_event_start_date';
			$args_past['meta_type'] = 'DATETIME';
		}

		$args_past = apply_filters('event_manager_past_event_listings_args', $args_past);
		$past_events = new WP_Query($args_past);

		wp_reset_query();

		// remove calender view
		remove_action('end_event_listing_layout_icon', 'add_event_listing_calendar_layout_icon');

		if($past_events->have_posts()) : ?>
			<div class="past_event_listings">
				<?php get_event_manager_template('event-listings-start.php', array('layout_type' => $layout_type, 'title' => $title));
				while ($past_events->have_posts()) : $past_events->the_post();
					get_event_manager_template_part('content', 'past_event_listing');
				endwhile;
				get_event_manager_template('event-listings-end.php');
				if($past_events->found_posts > $per_page) :
					if($show_pagination == "true") : ?>
						<div class="event-organizer-pagination wpem-col-12">
							<?php get_event_manager_template('pagination.php', array('max_num_pages' => $past_events->max_num_pages)); ?>
						</div>
					<?php endif;
				endif; ?>
			</div>
		<?php else :
			do_action('event_manager_output_events_no_results');
		endif;
		wp_reset_postdata();
		$event_listings_output = apply_filters('event_manager_past_event_listings_output', ob_get_clean());
		return  $event_listings_output;
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_register] Shortcode

The WP-Event-Manager shortcode ‘event_register’ is used to display the registration details for a specific event. It queries the ‘event_listing’ post type and outputs the registration method.

Shortcode: [event_register]

Parameters

Here is a list of all possible event_register shortcode parameters and attributes:

  • id – The unique ID of the specific event listing.

Examples and Usage

Basic example – Displays the registration details of a specific event by referencing the event’s ID.

[event_register id=1 /]

Advanced examples

Using the shortcode to display the registration details of a specific event by referencing the event’s ID. If no event with the specified ID is found, the shortcode will return an empty string.

[event_register id=2 /]

Another advanced usage of the shortcode can be to display the registration details of an event, but this time without specifying the ID. This will also return an empty string as the ID is a required attribute for the shortcode to function correctly.

[event_register /]

PHP Function Code

In case you have difficulties debugging what causing issues with [event_register] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_register', array($this, 'output_event_register'));

Shortcode PHP function:

function output_event_register($atts){
		extract(shortcode_atts(array(
			'id'       => ''
		), $atts));

		ob_start();

		$args = array(
			'post_type'   => 'event_listing',
			'post_status' => 'publish'
		);

		if(!$id) {
			return '';
		} else {
			$args['p'] = absint($id);
		}
		$events = new WP_Query($args);
		if($events->have_posts()) :
			while ($events->have_posts()) : $events->the_post(); ?>
				<div class="event-manager-registration-wrapper">
					<?php
					$register = get_event_registration_method();
					do_action('event_manager_registration_details_' . $register->type, $register); ?>
				</div>
			<?php endwhile;
		endif;
		wp_reset_postdata();
		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [upcoming_events] Shortcode

The WP-Event-Manager shortcode ‘upcoming_events’ displays a list of upcoming events. It allows customization of event display based on various parameters like location, keywords, and categories. It uses the ‘event_listing’ post type and filters events that are not cancelled and have a start or end date in the future. Pagination, ordering, and layout options are also available.

Shortcode: [upcoming_events]

Parameters

Here is a list of all possible upcoming_events shortcode parameters and attributes:

  • show_pagination – decides whether to show pagination or not
  • per_page – defines the number of events displayed per page
  • order – sets the order of events, ascending or descending
  • orderby – determines the field to order the events by
  • location – filters the events based on their location
  • keywords – filters the events based on specific keywords
  • selected_datetime – filters events according to selected date and time
  • selected_categories – filters events based on selected categories
  • selected_event_types – filters events according to selected event types
  • layout_type – defines the layout type for displaying the events
  • title – sets the title of the events section

Examples and Usage

Basic example – Displays the upcoming events without any specific parameters. The default settings of the plugin will be used.

[upcoming_events]

Advanced examples

Display upcoming events, sorted in ascending order, with a maximum of 10 events per page.

[upcoming_events order="ASC" per_page="10"]

Show upcoming events from a specific location with the keyword ‘music’.

[upcoming_events location="New York" keywords="music"]

Display upcoming events from a specific category and type.

[upcoming_events selected_categories="music,art" selected_types="festival,concert"]

Display upcoming events that occur between specific dates.

[upcoming_events selected_datetime="2022-05-01,2022-05-31"]

Show upcoming events with pagination turned off.

[upcoming_events show_pagination="false"]

These examples demonstrate the versatility of the shortcode and how it can be customized to display upcoming events based on various parameters.

PHP Function Code

In case you have difficulties debugging what causing issues with [upcoming_events] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('upcoming_events', array($this, 'output_upcoming_events'));

Shortcode PHP function:

function output_upcoming_events($atts)	{

		ob_start();
		extract(shortcode_atts(array(
			'show_pagination'           => true,
			'per_page'                  => get_option('event_manager_per_page'),
			'order'                     => 'DESC',
			'orderby'                   => isset($atts['meta_key']) ? sanitize_text_field($atts['meta_key']) : 'event_start_date', // meta_value
			'location'                  => '',
			'keywords'                  => '',
			'selected_datetime'         => '',
			'selected_categories'       => isset($atts['selected_categories']) ? $atts['selected_categories'] :  '',
			'selected_event_types'      => isset($atts['selected_types']) ? $atts['selected_types'] :  '',
			'layout_type'      			=> 'all',
			'title'                     => __('Upcoming Events', 'wp-event-manager'),
		), $atts));

		$paged = is_front_page() ? max(1, get_query_var('page')) : max(1, get_query_var('paged'));

		$args = array(
			'post_type'  	=> 'event_listing',
			'post_status'	=> array('publish'),
			'posts_per_page' => $per_page,
			'paged'			=> $paged,
			'order'			=> $order,
			'orderby'		=> $orderby,
		);

		$args['meta_query'] = array(
			array(
				'relation' => 'OR',
				array(
					'key'     => '_event_start_date',
					'value'   => current_time('Y-m-d H:i:s'),
					'type'    => 'DATETIME',
					'compare' => '>='
				),
				array(
					'key'     => '_event_end_date',
					'value'   => current_time('Y-m-d H:i:s'),
					'type'    => 'DATETIME',
					'compare' => '>='
				)
			),
			array(
				'key'     => '_cancelled',
				'value'   => '1',
				'compare' => '!='
			),
		);

		if(!empty($keywords)) {
			$args['s'] = $keywords;
		}

		if(!empty($selected_categories)) {
			$categories = explode(',', sanitize_text_field($selected_categories));
			$args['tax_query'][] = [
				'taxonomy'	=> 'event_listing_category',
				'field'   	=> 'name',
				'field'   	=> 'slug',
				'terms'   	=> $categories,
			];
		}

		if(!empty($selected_event_types)) {
			$event_types = explode(',', sanitize_text_field($selected_event_types));
			$args['tax_query'][] = [
				'taxonomy'	=> 'event_listing_type',
				'field'   	=> 'name',
				'field'   	=> 'slug',
				'terms'   	=> $event_types,
			];
		}

		if(!empty($selected_datetime)) {
			$datetimes = explode(',', $selected_datetime);
			$args['meta_query'][] = [
				'key' => '_event_start_date',
				'value'   => $datetimes,
				'compare' => 'BETWEEN',
				'type'    => 'date'
			];
		}

		if(!empty($location)) {
			$args['meta_query'][] = [
				'key' 		=> '_event_location',
				'value'  	=> $location,
				'compare'	=> 'LIKE'
			];
		}

		if('event_start_date' === $args['orderby']) {
			$args['orderby'] = 'meta_value';
			$args['meta_key'] = '_event_start_date';
			$args['meta_type'] = 'DATETIME';
		}

		$args = apply_filters('event_manager_upcoming_event_listings_args', $args);
		$upcoming_events = new WP_Query($args);

		wp_reset_query();

		// remove calender view
		remove_action('end_event_listing_layout_icon', 'add_event_listing_calendar_layout_icon');

		if($upcoming_events->have_posts()) : ?>
			<div class="event_listings">
				<?php get_event_manager_template('event-listings-start.php', array('layout_type' => $layout_type, 'title' => $title));
				while ($upcoming_events->have_posts()) : $upcoming_events->the_post();
					get_event_manager_template_part('content', 'past_event_listing');
				endwhile;
				get_event_manager_template('event-listings-end.php');
				if($upcoming_events->found_posts > $per_page) :
					if($show_pagination == "true" || $show_pagination == "on") : ?>
						<div class="event-organizer-pagination">
							<?php get_event_manager_template('pagination.php', array('max_num_pages' => $upcoming_events->max_num_pages)); ?>
						</div>
					<?php endif;
				 endif; ?>

			</div>
		<?php else :
			do_action('event_manager_output_events_no_results');
		endif;

		wp_reset_postdata();
		$event_listings_output = apply_filters('event_manager_upcoming_event_listings_output', ob_get_clean());
		return  $event_listings_output;
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [submit_organizer_form] Shortcode

The WP Event Manager shortcode ‘submit_organizer_form’ allows users to display a form on their website for organizers to submit their event details. This shortcode calls the ‘submit-organizer’ form from the event manager, enabling website visitors to enter and submit their event information.

Shortcode: [submit_organizer_form]

Examples and Usage

Basic example – A simple shortcode usage to display the organizer submission form on a page.

[submit_organizer_form /]

PHP Function Code

In case you have difficulties debugging what causing issues with [submit_organizer_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('submit_organizer_form', array($this, 'submit_organizer_form'));

Shortcode PHP function:

function submit_organizer_form($atts = array()){
		return $GLOBALS['event_manager']->forms->get_form('submit-organizer', $atts);
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [organizer_dashboard] Shortcode

The WP Event Manager’s shortcode, ‘organizer_dashboard’, manages the display of organizer listings. It checks if a user is logged in and displays a sign-in prompt if not. It also sets the number of posts per page and enqueues a script for the organizer dashboard. It has conditional content based on user actions and displays the organizer dashboard with the organizers’ details. Shortcode: [organizer_dashboard]

Shortcode: [organizer_dashboard]

Examples and Usage

Basic example – Displays the organizer dashboard for the logged-in user. If no user is logged in, a sign-in prompt will be displayed.

[organizer_dashboard /]

PHP Function Code

In case you have difficulties debugging what causing issues with [organizer_dashboard] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('organizer_dashboard', array($this, 'organizer_dashboard'));

Shortcode PHP function:

function organizer_dashboard($atts){

		if(!is_user_logged_in()) {
			ob_start(); ?>
			<div id="event-manager-event-dashboard">
				<p class="account-sign-in wpem-alert wpem-alert-info"><?php _e('You need to be signed in to manage your organizer listings.', 'wp-event-manager'); ?> <a href="<?php echo apply_filters('event_manager_event_dashboard_login_url', esc_url(get_option('event_manager_login_page_url'),esc_url(wp_login_url()))); ?>"><?php _e('Sign in', 'wp-event-manager'); ?></a></p>
			</div>
			<?php 
			return ob_get_clean();
		}

		extract(shortcode_atts(array(
			'posts_per_page' => '10',
		), $atts));

		wp_enqueue_script('wp-event-manager-organizer-dashboard');

		ob_start();

		// If doing an action, show conditional content if needed....
		if(!empty($_REQUEST['action'])) {
			$action = sanitize_title($_REQUEST['action']);

			// Show alternative content if a plugin wants to
			if(has_action('event_manager_organizer_dashboard_content_' . $action)) {
				do_action('event_manager_organizer_dashboard_content_' . $action, $atts);
				return ob_get_clean();
			}
		}

		// ....If not show the event dashboard
		$args = apply_filters('event_manager_get_dashboard_organizers_args', array(
			'post_type'           => 'event_organizer',
			'post_status'         => array('publish'),
			'ignore_sticky_posts' => 1,
			'posts_per_page'      => $posts_per_page,
			'offset'              => (max(1, get_query_var('paged')) - 1) * $posts_per_page,
			'orderby'             => 'date',
			'order'               => 'desc',
			'author'              => get_current_user_id()
		));

		$organizers = new WP_Query;
		echo esc_html($this->organizer_dashboard_message);

		$organizer_dashboard_columns = apply_filters('event_manager_organizer_dashboard_columns', array(
			'organizer_name' => __('Organizer name', 'wp-event-manager'),
			'organizer_details' => __('Details', 'wp-event-manager'),
			'organizer_events' => __('Events', 'wp-event-manager'),
			'organizer_action' => __('Action', 'wp-event-manager'),
		));

		get_event_manager_template(
			'organizer-dashboard.php',
			array(
				'organizers' => $organizers->query($args),
				'max_num_pages' => $organizers->max_num_pages,
				'organizer_dashboard_columns' => $organizer_dashboard_columns
			),
			'wp-event-manager/organizer',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/organizer'
		);

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_organizers] Shortcode

The WP-Event Manager shortcode ‘event_organizers’ is designed to output a list of event organizers. It fetches all the organizers, sorts and displays them based on specified attributes. This shortcode can be customized to order the list by title, show organizer thumbnails, and display the total event count. The output is then formatted and returned for display on the website.

Shortcode: [event_organizers]

Parameters

Here is a list of all possible event_organizers shortcode parameters and attributes:

  • orderby – Determines the sorting method of the organizers.
  • order – Sets the direction of the sorting, ascending or descending.
  • show_thumb – If true, displays organizer’s thumbnail images.
  • show_count – If true, shows the count of all events for each organizer.

Examples and Usage

Basic example – Displaying event organizers in ascending order by title with both thumbnail and event count shown.

[event_organizers orderby="title" order="ASC" show_thumb="true" show_count="true" /]

Advanced examples

Displaying event organizers in descending order by title without showing the thumbnail but with the event count.

[event_organizers orderby="title" order="DESC" show_thumb="false" show_count="true" /]

Showing event organizers in ascending order without the thumbnail and event count.

[event_organizers orderby="title" order="ASC" show_thumb="false" show_count="false" /]

Displaying event organizers without specifying the order, but with both thumbnail and event count shown.

[event_organizers show_thumb="true" show_count="true" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [event_organizers] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_organizers', array($this, 'output_event_organizers'));

Shortcode PHP function:

function output_event_organizers($atts)	{
		extract($atts = shortcode_atts(apply_filters('event_manager_output_event_organizers_defaults', array(
			'orderby'	=> 'title', // title
			'order'     => 'ASC',
			'show_thumb'	=> true,
			'show_count'	=> true,
		)), $atts));
		ob_start();

		$args = [
			'orderby' 	=> $orderby,
			'order'		=> $order,
		];

		$organizers   = get_all_organizer_array('', $args);
		$countAllEvents = get_event_organizer_count();
		$organizers_array = [];

		if(!empty($organizers)) {
			foreach ($organizers as $organizer_id => $organizer) {
				$organizers_array[strtoupper($organizer[0])][$organizer_id] = $organizer;
			}
		}

		wp_enqueue_script('wp-event-manager-organizer');

		get_event_manager_template(
			'event-organizers.php',
			array(
				'organizers'		=> $organizers,
				'organizers_array'  => $organizers_array,
				'countAllEvents'    => $countAllEvents,
				'show_thumb'		=> $show_thumb,
				'show_count'		=> $show_count,
			),
			'wp-event-manager/organizer',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/organizer/'
		);

		wp_reset_postdata();

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_organizer] Shortcode

The WP Event Manager shortcode, ‘event_organizer’, is designed to output event organizer details. It fetches the organizer’s ID and displays all associated event listings. This shortcode queries for upcoming, current, and past events linked to the organizer. It also enables pagination and loads the ‘content-single-event_organizer.php’ template.

Shortcode: [event_organizer]

Parameters

Here is a list of all possible event_organizer shortcode parameters and attributes:

  • id – The unique identifier of the event organizer

Examples and Usage

Basic Example: – A simple usage of the shortcode to display the event organizer by referencing the ID.

[event_organizer id=1 /]

Advanced Examples:

Displaying an event organizer with a specific ID. If the organizer with the given ID is not found, it will not return anything. This is useful when you want to display a specific event organizer on your page.

[event_organizer id=3 /]

Example of using the shortcode with an invalid ID. This will not display anything, as the organizer with ID 9999 does not exist. This can be used for testing purposes or to ensure that an invalid ID does not break your page.

[event_organizer id=9999 /]

Please note that the ID attribute in the shortcode is mandatory. If you do not provide an ID or if you provide an invalid ID, the shortcode will not display anything.

PHP Function Code

In case you have difficulties debugging what causing issues with [event_organizer] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_organizer', array($this, 'output_event_organizer'));

Shortcode PHP function:

function output_event_organizer($atts)	{
		extract(shortcode_atts(array(
			'id' => '',
		), $atts));

		if(!$id)
			return;

		ob_start();

		$args = array(
			'post_type'   => 'event_organizer',
			'post_status' => 'publish',
			'p'           => $id
		);

		$organizers = new WP_Query($args);

		if(empty($organizers->posts))
			return;

		ob_start();

		$organizer    = $organizers->posts[0];
		$paged           = (get_query_var('paged')) ? get_query_var('paged') : 1;
		$current_page    = isset($_REQUEST['pagination']) ? sanitize_text_field($_REQUEST['pagination']) : sanitize_text_field($paged);
		$per_page        = 10;
		$today_date      = date("Y-m-d");
		$organizer_id    = $organizer->ID;
		$show_pagination = true;

		$args_upcoming = array(
			'post_type'      => 'event_listing',
			'post_status'    => 'publish',
			'posts_per_page' => $per_page,
			'paged'          => $current_page
		);

		$args_upcoming['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key'     => '_event_organizer_ids',
				'value'   => $organizer_id,
				'compare' => 'LIKE',
			),
			array(
				'key'     => '_event_start_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '>'
			)
		);

		$upcomingEvents = new WP_Query(apply_filters('wpem_single_organizer_upcoming_event_listing_query_args', $args_upcoming));
		wp_reset_query();

		$args_current = $args_upcoming;

		$args_current['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key'     => '_event_organizer_ids',
				'value'   => $organizer_id,
				'compare' => 'LIKE',
			),
			array(
				'key'     => '_event_start_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '<='
			),
			array(
				'key'     => '_event_end_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '>='
			)
		);

		$currentEvents = new WP_Query(apply_filters('wpem_single_organizer_current_event_listing_query_args', $args_current));
		wp_reset_query();

		$args_past = array(
			'post_type'      => 'event_listing',
			'post_status'    => array('expired', 'publish'),
			'posts_per_page' => $per_page,
			'paged'          => $paged
		);

		$args_past['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key'     => '_event_organizer_ids',
				'value'   => $organizer_id,
				'compare' => 'LIKE',
			),
			array(
				'key'     => '_event_end_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '<'
			)
		);
		$pastEvents              = new WP_Query(apply_filters('wpem_single_organizer_past_event_listing_query_args', $args_past));
		wp_reset_query();

		do_action('organizer_content_start');

		wp_enqueue_script('wp-event-manager-organizer');

		get_event_manager_template(
			'content-single-event_organizer.php',
			array(
				'organizer_id'    => $organizer_id,
				'per_page'        => $per_page,
				'show_pagination' => $show_pagination,
				'upcomingEvents'  => $upcomingEvents,
				'currentEvents'   => $currentEvents,
				'pastEvents'      => $pastEvents,
				'current_page'    => $current_page,
			),
			'wp-event-manager/organizer',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/organizer/'
		);

		wp_reset_postdata();

		do_action('organizer_content_end');

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [single_event_organizer] Shortcode

The WP-Event-Manager shortcode ‘single_event_organizer’ displays details of a specific event organizer. It takes an ‘id’ attribute to fetch the relevant organizer’s data. This shortcode queries the ‘event_listing’ post type, verifies its published status, and retrieves the post based on the provided ID. If no posts are found, it returns nothing. The shortcode initiates the ‘single_event_organizers_content_start’ action, loads the ‘content-single-event-organizers.php’ template, and then ends with the ‘single_event_organizers_content_end’ action. This allows you to display detailed information about an event organizer on your WordPress site.

Shortcode: [single_event_organizer]

Parameters

Here is a list of all possible single_event_organizer shortcode parameters and attributes:

  • id – It represents the unique identifier of the event.

Examples and Usage

Basic example – The following shortcode is used to display a single event organizer by referencing the ID of the event. The event organizer will be displayed only if an event with the specified ID exists and is published.

[single_event_organizer id=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [single_event_organizer] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('single_event_organizer', array($this, 'output_single_event_organizer'));

Shortcode PHP function:

function output_single_event_organizer($atts)	{
		extract(shortcode_atts(array(
			'id' => '',
		), $atts));

		if(!$id)
			return;

		ob_start();

		$args = array(
			'post_type'   => 'event_listing',
			'post_status' => 'publish',
			'p'           => $id
		);

		$event = new WP_Query($args);

		if(empty($event->posts))
			return;

		ob_start();

		do_action('single_event_organizers_content_start');

		get_event_manager_template(
			'content-single-event-organizers.php',
			array(
				'event'    	  => $event,
				'event_id'    => $id,
			),
			'wp-event-manager/organizer',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/organizer'
		);

		wp_reset_postdata();

		do_action('single_event_organizers_content_end');

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [submit_venue_form] Shortcode

The WP-Event-Manager shortcode ‘submit_venue_form’ allows users to submit a venue form on a WordPress site. This shortcode calls the ‘submit_venue_form’ function, which retrieves the ‘submit-venue’ form from the Event Manager plugin. This form can be customized based on the attributes provided.

Shortcode: [submit_venue_form]

Examples and Usage

Basic example – The basic usage of the shortcode to display the venue submission form on a page or post.

[submit_venue_form]

PHP Function Code

In case you have difficulties debugging what causing issues with [submit_venue_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('submit_venue_form', array($this, 'submit_venue_form'));

Shortcode PHP function:

function submit_venue_form($atts = array()){
		return $GLOBALS['event_manager']->forms->get_form('submit-venue', $atts);
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [venue_dashboard] Shortcode

The WP-Event-Manager shortcode ‘venue_dashboard’ is designed to manage venue listings on your website. It checks if the user is logged in and, if not, prompts them to sign in. It allows users to perform actions and display content conditionally. If no action is specified, it displays the venue dashboard. The dashboard includes venue name, details, events, and actions. It also enqueues the ‘wp-event-manager-venue-dashboard’ script and sets the number of posts per page. The shortcode uses the WP_Query class to retrieve venue posts from the database.

Shortcode: [venue_dashboard]

Examples and Usage

Basic example – A simple usage of the ‘venue_dashboard’ shortcode to manage your venue listings. This shortcode will display the venue dashboard, but only if the user is logged in.

[venue_dashboard /]

PHP Function Code

In case you have difficulties debugging what causing issues with [venue_dashboard] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('venue_dashboard', array($this, 'venue_dashboard'));

Shortcode PHP function:

function venue_dashboard($atts)	{
		if(!is_user_logged_in()) {
			ob_start();	?>
			<div id="event-manager-event-dashboard">
				<p class="account-sign-in wpem-alert wpem-alert-info"><?php _e('You need to be signed in to manage your venue listings.', 'wp-event-manager'); ?> <a href="<?php echo apply_filters('event_manager_event_dashboard_login_url', esc_url(get_option('event_manager_login_page_url'),esc_url(wp_login_url()))); ?>"><?php _e('Sign in', 'wp-event-manager'); ?></a></p>
			</div>
			<?php 
			return ob_get_clean();
		}

		extract(shortcode_atts(array(
			'posts_per_page' => '10',
		), $atts));

		wp_enqueue_script('wp-event-manager-venue-dashboard');

		ob_start();

		// If doing an action, show conditional content if needed....
		if(!empty($_REQUEST['action'])) {
			$action = sanitize_title($_REQUEST['action']);
			// Show alternative content if a plugin wants to
			if(has_action('event_manager_venue_dashboard_content_' . $action)) {

				do_action('event_manager_venue_dashboard_content_' . $action, $atts);

				return ob_get_clean();
			}
		}

		// ....If not show the event dashboard
		$args     = apply_filters('event_manager_get_dashboard_venue_args', array(
			'post_type'           => 'event_venue',
			'post_status'         => array('publish'),
			'ignore_sticky_posts' => 1,
			'posts_per_page'      => $posts_per_page,
			'offset'              => (max(1, get_query_var('paged')) - 1) * $posts_per_page,
			'orderby'             => 'date',
			'order'               => 'desc',
			'author'              => get_current_user_id()
		));

		$venues = new WP_Query;

		echo esc_html($this->venue_dashboard_message);

		$venue_dashboard_columns = apply_filters('event_manager_venue_dashboard_columns', array(
			'venue_name' => __('Venue name', 'wp-event-manager'),
			'venue_details' => __('Details', 'wp-event-manager'),
			'venue_events' => __('Events', 'wp-event-manager'),
			'venue_action' => __('Action', 'wp-event-manager'),
		));

		get_event_manager_template(
			'venue-dashboard.php',
			array(
				'venues' => $venues->query($args),
				'max_num_pages' => $venues->max_num_pages,
				'venue_dashboard_columns' => $venue_dashboard_columns
			),
			'wp-event-manager/venue',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/venue'
		);

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_venues] Shortcode

The WP Event Manager shortcode ‘event_venues’ is designed to display all event venues. It sorts them by title in ascending order, showing both thumbnail and count by default. The PHP function ‘output_event_venues’ extracts attributes, creates an array of venues, and initiates the venue content. It queues the ‘wp-event-manager-venue’ script, retrieves the ‘event-venues.php’ template, and resets post data.

Shortcode: [event_venues]

Parameters

Here is a list of all possible event_venues shortcode parameters and attributes:

  • orderby – defines the sorting parameter for the venues
  • order – determines the order of the venues, ascending or descending
  • show_thumb – controls the display of venue thumbnails
  • show_count – controls the display of the count of venues

Examples and Usage

Basic example – Displaying event venues using default parameters

[event_venues]

Advanced examples

Displaying event venues ordered by title in descending order

[event_venues orderby="title" order="DESC"]

Displaying event venues without the thumbnail and count

[event_venues show_thumb=false show_count=false]

Combining parameters to display event venues ordered by title in descending order without the thumbnail but with the count

[event_venues orderby="title" order="DESC" show_thumb=false show_count=true]

PHP Function Code

In case you have difficulties debugging what causing issues with [event_venues] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_venues', array($this, 'output_event_venues'));

Shortcode PHP function:

function output_event_venues($atts)	{
		extract($atts = shortcode_atts(apply_filters('event_manager_output_event_venues_defaults', array(
			'orderby'	=> 'title', // title
			'order'     => 'ASC',
			'show_thumb'	=> true,
			'show_count'	=> true,
		)), $atts));

		ob_start();

		$args = [
			'orderby' 	=> $orderby,
			'order'		=> $order,
		];

		$venues   = get_all_venue_array('', $args);
		$countAllEvents = get_event_venue_count();
		$venues_array = [];

		if(!empty($venues)) {
			foreach ($venues as $venue_id => $venue) {
				$venues_array[strtoupper($venue[0])][$venue_id] = $venue;
			}
		}

		do_action('venue_content_start');

		wp_enqueue_script('wp-event-manager-venue');

		get_event_manager_template(
			'event-venues.php',
			array(
				'venues'			=> $venues,
				'venues_array'  	=> $venues_array,
				'countAllEvents'	=> $countAllEvents,
				'show_thumb'		=> $show_thumb,
				'show_count'		=> $show_count,
			),
			'wp-event-manager/venue',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/venue/'
		);

		do_action('venue_content_end');

		wp_reset_postdata();

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [event_venue] Shortcode

The WP Event Manager shortcode, ‘event_venue’, is used to display event venue details. It fetches the venue ID and displays relevant data. This shortcode queries the ‘event_venue’ post type, and if the venue ID is valid, it shows the venue’s associated events. It categorizes these into upcoming, current, and past events, based on the event’s start and end dates.

Shortcode: [event_venue]

Parameters

Here is a list of all possible event_venue shortcode parameters and attributes:

  • id – unique identifier for the event venue

Examples and Usage

Basic example – Display the venue details by referencing the venue ID.

[event_venue id=123 /]

In this basic example, the shortcode is used to display the details of the venue with the ID 123. The details will be fetched from the ‘event_venue’ post type and displayed on the page.

Advanced examples

Display the venue details by referencing the venue ID and customizing the number of events per page.

[event_venue id=123 per_page=20 /]

In this advanced example, the shortcode is used to display the details of the venue with the ID 123, and it also customizes the number of events per page to 20. The details will be fetched from the ‘event_venue’ post type and displayed on the page, with the number of events per page set to 20.

Please note that the ‘per_page’ attribute is not directly supported by the shortcode and requires modifications to the PHP function handling the shortcode to work.

PHP Function Code

In case you have difficulties debugging what causing issues with [event_venue] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('event_venue', array($this, 'output_event_venue'));

Shortcode PHP function:

function output_event_venue($atts)	{
		extract(shortcode_atts(array(
			'id' => '',
		), $atts));

		if(!$id)
			return;

		$args = array(
			'post_type'   => 'event_venue',
			'post_status' => 'publish',
			'p'           => $id
		);

		$venues = new WP_Query($args);

		if(empty($venues->posts))
			return;

		ob_start();

		$venue    = $venues->posts[0];
		$paged           = (get_query_var('paged')) ? get_query_var('paged') : 1;
		$per_page        = 10;
		$today_date      = date("Y-m-d");
		$venue_id    	 = $venue->ID;
		$show_pagination = true;

		$args_upcoming = array(
			'post_type'      => 'event_listing',
			'post_status'    => 'publish',
			'posts_per_page' => $per_page,
			'paged'          => $paged
		);

		$args_upcoming['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key'     => '_event_venue_ids',
				'value'   => $venue_id,
				'compare' => 'LIKE',
			),
			array(
				'key'     => '_event_start_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '>'
			)
		);

		$upcomingEvents = new WP_Query($args_upcoming);
		wp_reset_query();

		$args_current = $args_upcoming;

		$args_current['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key'     => '_event_venue_ids',
				'value'   => $venue_id,
				'compare' => 'LIKE',
			),
			array(
				'key'     => '_event_start_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '<='
			),
			array(
				'key'     => '_event_end_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '>='
			)
		);

		$currentEvents = new WP_Query($args_current);
		wp_reset_query();

		$args_past = array(
			'post_type'      => 'event_listing',
			'post_status'    => array('expired', 'publish'),
			'posts_per_page' => $per_page,
			'paged'          => $paged
		);

		$args_past['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key'     => '_event_venue_ids',
				'value'   => $venue_id,
				'compare' => 'LIKE',
			),
			array(
				'key'     => '_event_end_date',
				'value'   => $today_date,
				'type'    => 'date',
				'compare' => '<'
			)
		);
		$pastEvents              = new WP_Query($args_past);
		wp_reset_query();

		do_action('venue_content_start');

		wp_enqueue_script('wp-event-manager-venue');

		get_event_manager_template(
			'content-single-event_venue.php',
			array(
				'venue_id'    	  => $venue_id,
				'per_page'        => $per_page,
				'show_pagination' => $show_pagination,
				'upcomingEvents'  => $upcomingEvents,
				'currentEvents'   => $currentEvents,
				'pastEvents'      => $pastEvents,
			),
			'wp-event-manager/venue',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/venue/'
		);

		wp_reset_postdata();

		do_action('venue_content_end');

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

WP Event Manager [single_event_venue] Shortcode

The WP Event Manager shortcode, ‘single_event_venue’, is designed to display a single event’s venue details. It fetches the event data based on the ‘id’ passed in the shortcode. The PHP function ‘output_single_event_venue’ extracts the ‘id’ from the shortcode attributes. It then queries the event listing post type, using the provided ‘id’. If a valid event is found, it triggers the ‘single_event_venues_content_start’ action, loads the ‘content-single-event-venues.php’ template with the relevant event data, and finally triggers ‘single_event_venues_content_end’ action. The output is then returned and displayed on the webpage where the shortcode is used.

Shortcode: [single_event_venue]

Parameters

Here is a list of all possible single_event_venue shortcode parameters and attributes:

  • id – The unique identifier of the specific event listing.

Examples and Usage

Basic example – The following shortcode is used to display a single event venue by referencing its ID. The event venue will load based on the provided ID.

[single_event_venue id=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [single_event_venue] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('single_event_venue', array($this, 'output_single_event_venue'));

Shortcode PHP function:

function output_single_event_venue($atts)	{
		extract(shortcode_atts(array(
			'id' => '',
		), $atts));

		if(!$id)
			return;

		ob_start();

		$args = array(
			'post_type'   => 'event_listing',
			'post_status' => 'publish',
			'p'           => $id
		);

		$event = new WP_Query($args);

		if(empty($event->posts))
			return;

		ob_start();

		do_action('single_event_venues_content_start');

		get_event_manager_template(
			'content-single-event-venues.php',
			array(
				'event'    	  => $event,
				'event_id'    => $id,
			),
			'wp-event-manager/venue',
			EVENT_MANAGER_PLUGIN_DIR . '/templates/venue'
		);

		wp_reset_postdata();

		do_action('single_event_venues_content_end');

		return ob_get_clean();
	}

Code file location:

wp-event-manager/wp-event-manager/shortcodes/wp-event-manager-shortcodes.php

Conclusion

Now that you’ve learned how to embed the WP Event Manager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *