Resolving Conflicts Between Post Types Order and The Events Calendar
Content
A common issue reported by users of the Post Types Order plugin is a conflict with The Events Calendar plugin by Modern Tribe. This conflict typically manifests on the calendar's list view, where clicking the 'Next' or 'Previous' pagination buttons causes events to appear in an incorrect, non-chronological order. A page refresh often corrects the order, indicating the problem is tied to AJAX requests used for pagination.
Why This Conflict Happens
WordPress treats AJAX requests as admin requests, even when they are initiated by visitors on the front end of a site. The Post Types Order plugin, when its 'Admin Sort' option is active, applies its custom sorting rules to these requests. This interferes with The Events Calendar's own intricate query system, which is designed to order events by their start date. The result is that the custom order from Post Types Order overrides the chronological event date order during AJAX pagination.
Most Common and Effective Solutions
Based on community reports and solutions, here are the most effective ways to resolve this conflict.
Solution 1: Disable Admin Sort for Events (Recommended First Step)
The simplest fix is to ensure the Post Types Order plugin is not trying to sort the events post type. Navigate to Settings → Post Types Order and verify that tribe_events is not selected in the list of post types for either 'Auto Sort' or 'Admin Sort'. This is often the quickest resolution.
Solution 2: Use a Custom Code Snippet
If the conflict persists even with the settings adjusted, a code filter can be used to explicitly tell Post Types Order to ignore queries from The Events Calendar. Add the following code to your theme's functions.php file or a custom functionality plugin:
function ignore_tribe_events_sort( $orderby, $query ) {
if ( isset( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] == 'tribe_events' ) {
return false;
}
return $orderby;
}
add_filter( 'pto/posts_orderby', 'ignore_tribe_events_sort', 10, 2 );
This code hooks into the plugin's filter and returns false for any query targeting the tribe_events post type, preventing custom sorting from being applied.
Solution 3: Disable Admin Sort Entirely
If you are not using the drag-and-drop order functionality in the WordPress admin dashboard for any post type, you can resolve this and similar AJAX conflicts by simply turning off the 'Admin Sort' option in the Post Types Order settings. This prevents the plugin from interfering with any AJAX-driven queries on the front end.
Conclusion
The conflict between Post Types Order and The Events Calendar is a well-documented issue rooted in how AJAX requests are handled. The solutions above, particularly using the custom code snippet, have proven effective for many users in allowing both plugins to function correctly on the same site. For more advanced scenarios, the 'Post Types Order' team has provided further documentation on their website for crafting more specific ignore rules.
Related Support Threads Support
-
exclude the events calendar postshttps://wordpress.org/support/topic/exclude-the-events-calendar-posts/
-
Conflict with Events Calendar by Modern Tribehttps://wordpress.org/support/topic/conflict-with-events-calendar-by-modern-tribe-2/
-
Conflict with Events Calendar by Modern Tribehttps://wordpress.org/support/topic/conflict-with-events-calendar-by-modern-tribe/
-
Tribe Events compatibilityhttps://wordpress.org/support/topic/tribe-events-compatibility/
-
The Events Calendar Pro Issuehttps://wordpress.org/support/topic/the-events-calendar-pro-issue/
-
Post Types Order breaks ajax requests in The Events Calendarhttps://wordpress.org/support/topic/post-types-order-breaks-ajax-requests-in-the-events-calendar/
-
Bug report: Incompatiblity with The Events Calendar Pluginhttps://wordpress.org/support/topic/bug-report-incompatiblity-with-the-events-calendar-plugin/
-
Sort No Longer Workinghttps://wordpress.org/support/topic/sort-no-longer-working/
-
Event Organiser pluginhttps://wordpress.org/support/topic/event-organiser-plugin-2/
-
"the events calendar" conflict with "post types order"?https://wordpress.org/support/topic/the-events-calendar-conflict-with-post-types-order/
-
Conflict with Events Calendar Shortcode Pluginhttps://wordpress.org/support/topic/conflict-with-events-calendar-shortcode-plugin/