Query only events that span multiple days

WordPress Event Management, Calendars & Registration Forums General Question Query only events that span multiple days

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 2 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40811

    Hi,
    is it possible to query only events that last more than one day?
    Thanks,
    Ilaria

    Ilaria Roglieri
    #40842

    Hi Ilaria,

    Unfortunately there is no API to specify this, but it should be possible by modifying the MySQL. Here is an example statement that pulls out all the event occurrences (and the underlying event’s post ID – that corresponds to the event post type in wp_posts table) for events where the start date of the occurrence is not the same as the end date:

    SELECT event_id as occurrence_id, post_id FROM wp_eo_events WHERE DATEDIFF(EndDate, StartDate) > 0

    You can either use that directly using $wpdb or there are WordPress filters that allow you to alter the SQL (i.e. posts_where) – note, that posts_where will apply to all SQL queries, so you would need to make sure you only apply the additional WHERE clause where you intend to.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.