Unexpected result by custom queries

WordPress Event Management, Calendars & Registration Forums General Question Unexpected result by custom queries

This topic contains 5 replies, has 2 voices, and was last updated by  Stephen Harris 7 years, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #27008

    Hi,
    I created a custom feed for the events to run a RSS based campaign at Mailchimp.
    It’s something that worked very well with other post types and event plugins.
    With EO I get a very strange result.
    I use these arguments for my query and it looks like your plugin add some additional filters.

    $args = array(
    'post_type' => 'event',
    'posts_per_page' => 10,
    'suppress_filters'=>false,
    'meta_query' => array(
        array (
            'key' => '_eventorganiser_schedule_start_start',
            'value' => current_time( 'mysql' ),
            'compare' => '>=',
            'type' => 'DATETIME'
        )
    ),
    

    );

    This is the query:

    SELECT SQL_CALC_FOUND_ROWS  wp_d946e71125_posts.*, wp_1_eo_events.event_id, wp_1_eo_events.event_id AS occurrence_id, wp_1_eo_events.StartDate, wp_1_eo_events.StartTime, wp_1_eo_events.EndDate, wp_1_eo_events.FinishTime, wp_1_eo_events.event_occurrence  FROM wp_d946e71125_posts  INNER JOIN wp_d946e71125_postmeta ON ( wp_d946e71125_posts.ID = wp_d946e71125_postmeta.post_id ) LEFT JOIN wp_1_eo_events ON wp_d946e71125_posts.ID = wp_1_eo_events.post_id  WHERE 1=1  AND ( 
    

    ( wp_d946e71125_postmeta.meta_key = ‘_eventorganiser_schedule_start_start’ AND CAST(wp_d946e71125_postmeta.meta_value AS DATETIME) >= ‘2017-04-15 21:35:09’ )
    ) AND wp_d946e71125_posts.post_type = ‘event’ AND (wp_d946e71125_posts.post_status = ‘publish’ OR wp_d946e71125_posts.post_status = ‘confirmed’ OR wp_d946e71125_posts.post_status = ‘private’) AND (wp_1_eo_events.EndDate > ‘2017-04-15’ OR (wp_1_eo_events.EndDate = ‘2017-04-15′ AND wp_1_eo_events.FinishTime > ’21:35:09’)) GROUP BY wp_1_eo_events.event_id ORDER BY wp_1_eo_events.StartDate ASC, wp_1_eo_events.StartTime ASC LIMIT 0, 10

    The whole part for endtime etc. shouldn’t be there, right?

    Olaf Lederer
    #27016

    You probably have the setting to not show past events enabled, which is what the FinishTime and EndDate are doing. If you want to remove that part of the query you can use

    'showpastevents' => true,
    

    in your $args. However, it wouldn’t make any difference to the return result set.

    Note that the FinishTime and EndDate are returning only future event dates. What you are doing is stronger: returning only event dates of events which have not had an occurrence yet. If you do not have any recurring events, then they are the same thing.

    Stephen Harris
    #27021

    HI Stephen,

    thanks for the reply. The problem in this query is that the result shows some events multiple time. Check http://maarssen.wordtest.nl/rss-feed-pagina-voor-events/

    Is could use a complete custom query to avoid all you filters, but it should work this way too.

    Olaf Lederer
    #27024

    By default it will show an entry for each occurrence. You could try 'group_events_by'=>'series'. This will mean each event will only appear at most once.

    Stephen Harris
    #27025

    The “group_events_by” argument has fixed that problem and the orderby “ID” argument provides the newest submissions first.
    Thanks I’m happy now 🙂

    Olaf Lederer
    #27027

    Orderby post_date is probably a better choice, but typically IDs and post date will give the same ordering.

    Stephen Harris
Viewing 6 posts - 1 through 6 (of 6 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.