Skip Navigation

[Resolved] Events no longer appear in the correct order

This support ticket is created 6 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 13 replies, has 3 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1130755
spotlights featured backend.PNG
featured issue 1.PNG

Recently after the update we found Events no longer showing properly. We did find the way to fix this in another forum ( https://toolset.com/forums/users/nigel-a/) . Changing the ordering from 'custom field' to 'number' worked for the most part, however events that last more than one day are appearing out of proper order.

Apparently the Event Calendar field ( _EventStartDate) must be formatting one-day and two-day dates differently. Please help! What can we do? We are paid customers for Toolset and for The Event Calendar Pro. There has to be some way that we can make these 2 talk to each other. It was all working perfectly before your recent update.

Link to a page where the issue can be seen: hidden link

#1131061

1. Apparently, the Event Calendar field ( _EventStartDate) must be formatting one-day and two-day dates differently.

That would be a problem, because you cannot sort by NUMBER or DATE or else simultaneously, in the Views.

2. What Update? Events Cal or Toolset? Do you have a copy of the working version of the site?
We could check what happened exactly.
Since it seems to be Toolset's update, there should be made a fix for it, of course.

3. Can you as well check, that you filter by NUMBER and not DATE, in no case?
Also, please consider this:
https://toolset.com/forums/topic/date-comparison-error-with-tribe-events-calendar-after-update/
https://toolset.com/forums/topic/the-event-calendar-todays-event-not-showing/

#1132811

Sorry this is the forum link I meant to connect you to. https://toolset.com/forums/topic/date-comparison-error-with-tribe-events-calendar-after-update/

We have the filter set to numbers not date. The update was specifically Toolset. It worked fine before that.

#1133280
order-by.JPG

Hello,

I assume we are talking about the plugin "The Events Calendar"
https://wordpress.org/plugins/the-events-calendar/

And you are going to query the "Events" posts, and order the result by custom field "_EventStartDate".

I have tried it in my localhost, it shores value in custom field "_EventStartDate" as string format, for example:
2018-11-23 00:00:00
2018-11-02 00:00:00
2018-11-04 00:00:00

So you can edit your post view, in section "Ordering", setup it as "As a native custom field"
see screenshot order-by.JPG

#1133521

That is how we initially had it. The method you mention stopped working on the last update. That is why we set it like this recent post told us to: https://toolset.com/forums/topic/date-comparison-error-with-tribe-events-calendar-after-update/

However in doing that only the single day events show up in order, now the multi day events do not. (see earlier screenshot).

#1134021

I had already tested with the multi day events, it works fine, see my answer:
https://toolset.com/forums/topic/events-no-longer-appear-in-the-correct-order/#post-1133280

I suggest you check these:
1) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again

2) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1134813
event-order.JPG

Thanks for the details, I can import the database dump file, I assume the table pre-fix is "wpfd_",
I have tried these:
1) Edit the post view "View Featured Spotlight Events for Home", in section "Ordering", switch to option "As a native custom field"
2) In section "Loop item in Featured Events for Home Page View", at the bottom, add a shortcode to display the "_EventStartDate" field value:

[wpv-post-field name="_EventStartDate"]

3) Test it in home page, it works fine, see screenshot event-order.JPG

Those items are display correctly in ascending order.

And the shortcode [wpv-post-field name="_EventStartDate"] does output the event start date correctly.

Is there anything missing?

#1135043

The screenshot doesn't look right: it's showing dates from 2014 instead of current dates. We should be seeing dates from the current date forward in order. We want to show all events from today's date forward.Please visit the home page of the live site: hidden link scroll down to Featured Upcoming Events. Make note of the 3 events showing and in what order. Then reload your screen. You will notice that the events are changing randomly every time you reload and they are not in order. Every time you reload it changes. This should not be happening.

#1135901
event-order2.JPG

Yes, you are right, I have added below codes codes in theme file functions.php:

function tssupp_filter_event_query( $view_args, $view_settings, $view_id ){
	if($view_id != 4219) return $view_args;
  if ( ! isset( $view_args['meta_query'] ) ) {
 
    $view_args['meta_query'] = array();
  }
 
  $meta_query = array(
 
    'key'     =>  '_EventStartDate',
    'value'   =>  date("Y-m-d H:i:s"),
    'type'    =>  'NUMBER',
    'compare' =>  '>'
  );
 
  $view_args['meta_query'][] = $meta_query;
   
  return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_filter_event_query', 101, 3 );

Now it does output the upcoming event posts, see screenshot:
event-order2.JPG

And the results are order by the "_EventStartDate" field correctly, I have tried reload the home page lots of time, the results are not changed, see above screenshot, so there should be some other custom codes/plugin/theme are changing the view's result, as I mentioned above, you will need to check this in your website:
In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again

#1138217

Can you clarify: do I need to ADD that code to my functions.php?

#1138794

Those PHP codes are copied from this thread you mentioned above:
https://toolset.com/forums/topic/date-comparison-error-with-tribe-events-calendar-after-update/

I am not sure where you have put them, maybe it is in your theme file "functions.php".

And the key problem is that:
There isn't similar problem in my localhost with a fresh wordpress installation, Views can order by the custom field _EventStartDate correctly.

As my above answer:
In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again

#1139147
screenshot-willowkeep.net-2018.11.02-16-51-41.png
screenshot-willowkeep.net-2018.11.02-16-51-26.png
screenshot-willowkeep.net-2018.11.02-16-50-51.png

Ok we have spent a whole day setting this up on a dev site on another server. Its even a different web host. We've switched to a default theme and turned off all other plugins. It still is out of order.

Here is the dev site: hidden link

Please try reloading the page at least 3 times. Included are screencaps of what happens when I do so.

We don't know what else to try.

#1139890
events.JPG

There isn't similar problem with only your database dump file in my localhost,I have tried to fresh the page lots of time, and get the same result, see screenshot, events.JPG

Please provide your test site credentials +FTP access in below private message box, I need a live website to test and debug. thanks

#1142788
upcoming.JPG

Thanks for the details, I have done below modification in your website:
1) Edit the view "View Featured Spotlight Events for Home",
in section "Ordering", setup it as "Ascending" + "As a native custom field", more details, please check my first answer:
https://toolset.com/forums/topic/events-no-longer-appear-in-the-correct-order/#post-1133280

2) Then test it again in the front-page, it works fine, see screenshot: