Support

Home Forums Event Espresso Premium WP Query + Ordering events by their date

WP Query + Ordering events by their date

Posted: July 20, 2014 at 11:40 am


Ryan DeBell

July 20, 2014 at 11:40 am

Hello,

I’m setting up a very small custom event list on a clients website using EE4.

So far it works great, however the events appear to be listed by their created date, rather than their actual event date.

What is the name of the key for the event start date?

Thanks


Ryan DeBell

July 20, 2014 at 12:08 pm

Cant seem to edit posts.
Anyway, it looks like its more than just adding a standard meta key parameters to the query.
How would i adjust the query to sort by event date? Below is my code. Note the count is used for displaying the events in a 2 column grid layout:

	<?php 
					$query = new WP_Query( 'posts_per_page=6&post_type=espresso_events' );
					$count = 0;
					if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();$count++; 
					if ($count%2== 0) : 
					?>


Dean

July 21, 2014 at 2:09 am

Hi,

Josh has made an example query that may help you out: https://gist.github.com/joshfeck/e3c9540cd4ccc734e755


Ryan DeBell

July 21, 2014 at 11:49 am

Perfect, that did exactly what I required. Many thanks

The support post ‘WP Query + Ordering events by their date’ 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