Support

Home Forums Event Espresso Premium Custom search for events between 2 dates

Custom search for events between 2 dates

Posted: December 13, 2016 at 11:26 am

Viewing 2 reply threads


Koen Linders

December 13, 2016 at 11:26 am

Hi I am trying to build a custom search for events. I am now working on the query as you can see below but It is not working.

<script src=”https://gist.github.com/kmlinders/12d02bad30654369744eb7d6c3e03df9.js”></script&gt;

Anyone know what I did wrong?


Koen Linders

December 13, 2016 at 11:29 am

			<?php
			
			$start = '2016-12-17';
			$end = '2017-01-31';
			
			$atts = array(
				'title' => NULL,
				'limit' => 24,
				'css_class' => NULL,
				'show_expired' => FALSE,
				'month' => NULL,
				'category_slug' => $event_categorie,
				'order_by' => 'start_date',
				'meta_query' => array(
					array(
						'key' => 'start_date',
						'value' => array($start, $end),
						'compare' => 'BETWEEN',
						'type' => 'DATE'
					)
				),
				'sort' => 'ASC'
			);
			// run the query
			global $wp_query;
			$wp_query = new EE_Event_List_Query( $atts );
				if (have_posts()) : while (have_posts()) : the_post();
			?>


Josh

  • Support Staff

December 13, 2016 at 12:02 pm

Hi Koen,

The event’s start dates are not stored as meta key/values of the post. Those are actually stored in the esp_datetime table.

Viewing 2 reply threads

The support post ‘Custom search for events between 2 dates’ 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