Posted: July 1, 2014 at 4:30 pm
|
Hello, I am trying to implement a custom code like this: <code><php $args = array( 'posts_per_page' => -1, 'offset' => 0, 'category' => '', 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'espresso_events', 'post_status' => 'publish', 'suppress_filters' => false ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <li> <?php $datetimes = $post->EE_Event->datetimes_ordered(); foreach($datetimes as $datetime) { $startDate = $datetime -> _DTT_EVT_start; } ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php echo $startDate;?> </li> <?php endforeach; ?> </code> It doesn’t seem to work. I mean, I can list events. But there is no way to actually: SORT events by date Can you confirm this? Tryin to use my code it throws a php error
I read your /classes/EE_Datetime.html#method_datetimes_ordered page and it says that property is protected. So…how can I use it to show a single event’s date using custom wordpress queries? Moreover, your documentation is incomplete, here -> https://eventespresso.com/wiki/ee4-custom-post-types/ you forgot to say that ”
|
|
Sorry, the code I sent was not easy to read. Trying again… <pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”><php $args = array( $myposts = get_posts( $args ); <?php $datetimes = $post->EE_Event->datetimes_ordered(); foreach($datetimes as $datetime) { <?php endforeach; ?> |
|
Hi, Sorry about the code syntax highlighter, it is temprmental. PAstebin is useful for code blocks. In answer, check out this code snippet written by Josh, https://gist.github.com/joshfeck/e3c9540cd4ccc734e755 It provides a way to query the EE events where they can also be sorted by things like event date. |
The support post ‘Get_posts -> how to get events listed by 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.