pending_review and draft posts showing in events_search shortcode

WordPress Event Management, Calendars & Registration Forums General Question pending_review and draft posts showing in events_search shortcode

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16054

    Hi,

    I’m using the event_search shortcode in a template like this:

    echo do_shortcode('[event_search filters="event_category,date"]');

    However the results are showing pending_review and drafts posts which shouldn’t be the case. I’m using the FES add-on to allow submission of events which are being set to pending_review automatically. These posts shouldn’t come up in the post listing until they’re published.

    If I echo out the sql generated by $eo_event_loop = new WP_Query( $query ); on line 412 of shortcodes.php it looks like this:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.*,
    wp_eo_events.event_id,
    wp_eo_events.event_id AS occurrence_id,
    wp_eo_events.StartDate,
    wp_eo_events.StartTime,
    wp_eo_events.EndDate,
    wp_eo_events.FinishTime,
    wp_eo_events.event_occurrence
    FROM wp_posts
    LEFT JOIN wp_eo_events ON wp_posts.id = wp_eo_events.post_id
    WHERE 1=1
    AND wp_posts.post_type = 'event'
    AND ((wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft' AND wp_posts.post_status <> 'expired'))
    AND (wp_eo_events.EndDate > '2015-04-06' OR (wp_eo_events.EndDate = '2015-04-06' AND wp_eo_events.FinishTime > '12:32:32'))
    ORDER BY wp_eo_events.StartDate ASC, wp_eo_events.StartTime ASC
    LIMIT 0, 10;

    It seems to only be filtering out trash, auto-draft and expired. How can I ensure that this shortcode only returns published posts?

    Thanks.

    VERB Interactive
    #16056

    Mmm… I’m not seeing this. Here’s what I get:

    AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'confirmed' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'private') 
    

    (As viewed by an admin, who can read private events – logged out users can’t see that).

    The status is not explicitly set, so it would perhaps be prudent to set it. E.g. adding

    'post_status'      => get_post_stati( array('public' => true) ),
    

    to the $query. I’ll be doing this in the next update.

    Stephen Harris
    #16067

    Hi Stephen,

    Turns out there was an issue with a custom plugin we’d built for the site that was interfering.

    Thanks for your quick reply!

    VERB Interactive
    #18374

    I never updated, this thread, but this bug was fixed in 1.10.3

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