Home › Forums › Calendar Products › Events Calendar PRO › Event end date and start date the same
- This topic has 5 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
April 24, 2015 at 7:23 am #958036
Neasa Ronayne
ParticipantI have reordered my events list to be ordered by end date by using this:
$args = array( 'meta_key'=> '_EventEndDate', 'meta_type'=>'DATE', 'orderby'=>'meta_value_num', 'post_type'=>'tribe_events', 'eventDisplay'=>'past', 'showposts' => '-1' ); $the_query = new WP_Query( $args );Unfortunately when my events are displayed/the query dumped the start date is set to the same date as the end date.
Has anyone encountered this before? Is there a reason for this?
Cheers
April 24, 2015 at 10:36 am #958130Zach Tirrell
KeymasterHi Philip,
It looks like you are trying to adjust the ordering, which should not be affecting the data in the _EventStartDate meta field.
I’m not sure the exact context of the snippet you shared. You may want to look at this tutorial on custom queries and pagination. It suggests the use of tribe_get_events() function which is a wrapper for get_posts that provides some useful functionality around fetching events.
If you could provide more detail around where you are using this and perhaps a dump of the data you are getting back that looks wrong, I may be able to help further.
April 28, 2015 at 2:15 am #958829Neasa Ronayne
ParticipantHi Zach,
Cheers for the reply, yeah I was thinking by reordering the data that shouldn’t impact on the data itself. When I change the meta_key to ‘_EventStartDate’ both start and end date appear as they should. I tried the tribe_get_events which unfortunately had the same results.What I have done is reorder posts by end date but this has caused the dates to become the same.
Here is the full snippet:<?php $args = array( 'meta_key'=> '_EventEndDate', 'meta_type'=>'DATE', 'orderby'=>'meta_value_num', 'post_type'=>'tribe_events', 'eventDisplay'=>'upcoming', 'showposts' => '-1' ); $the_query = new WP_Query( $args ); while ($the_query->have_posts()) : $the_query->the_post(); ?> /////The posts content <?php endwhile; wp_reset_query(); ?>Here is the dump of a single post:
object(WP_Post)#433 (26) { ["ID"]=> int(4567) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2015-02-09 11:58:36" ["post_date_gmt"]=> string(19) "2015-02-09 11:58:36" ["post_content"]=> string(872) "Sacred Space exhibition and accompanying book launch." ["post_title"]=> string(12) "Sacred Space" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(12) "sacred-space" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2015-02-19 12:26:31" ["post_modified_gmt"]=> string(19) "2015-02-19 12:26:31" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(62) "http://www.pivotdublin.com/?post_type=tribe_events&p=4567" ["menu_order"]=> int(55) ["post_type"]=> string(12) "tribe_events" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" ["EventStartDate"]=> string(19) "2015-05-01 23:59:59" ["EventEndDate"]=> string(19) "2015-05-01 23:59:59" }What it should look like:
object(WP_Post)#430 (26) { ["ID"]=> int(4567) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2015-02-09 11:58:36" ["post_date_gmt"]=> string(19) "2015-02-09 11:58:36" ["post_content"]=> string(872) "Sacred Space exhibition and accompanying book launch." ["post_title"]=> string(12) "Sacred Space" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(12) "sacred-space" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2015-02-19 12:26:31" ["post_modified_gmt"]=> string(19) "2015-02-19 12:26:31" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(62) "http://www.pivotdublin.com/?post_type=tribe_events&p=4567" ["menu_order"]=> int(55) ["post_type"]=> string(12) "tribe_events" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" ["EventStartDate"]=> string(19) "2015-02-12 00:00:00" ["EventEndDate"]=> string(19) "2015-05-01 23:59:59" }Any ideas Zach? Have you ever ordered by end date?
Cheers
April 29, 2015 at 8:51 am #959275Zach Tirrell
KeymasterOK, after a bunch of digging, (arguably too much since this whole topic falls outside our scope of support) I think your best path is to look at tapping into the post_orderby filter at a priority greater than 10.
Our code is doing a lot of stuff with the Order and Order By when relating to events. The end result is that some really strange stuff can happen when trying custom queries.
I wish I could help more, but this customization is proving to be fairly complicated and more than we can assist with in support.
April 29, 2015 at 8:58 am #959277Zach Tirrell
KeymasterOne other quick note, the inclusion of the
eventDisplayparameter in your query is odd. I thin that is deprecated and only intended for use on internal queries. I would try omitting that. Also, the ‘orderby’ would probably be better set to meta_value since the date is not a number.Perhaps those will help as well.
July 7, 2015 at 6:31 am #984124Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Event end date and start date the same’ is closed to new replies.
