WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Show only upcoming events in a slideshow (8 posts)

  1. HimSelf (Gregory)
    Member
    Posted 1 year ago #

    Hello,

    i'm trying to display events in a slideshow, it works perfect at one exception.

    the events are showing with passed events and i wanted it to show the next upcoming events only.

    this is my code :

    $slider = new WP_Query('post_type=event&orderby=event_start_date&order=DESC&showposts=5');

    Thanx in advance for your help / Merci d'avance pour votre aide

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

    You can use wp_query, the best way is to do this within the loop and use the EM_Event object.

    $EM_Event = get_em_event($post);

    However, all event values are stored as postmeta as well but with a _ at the start of the meta key e.g. _event_start_time

  3. HimSelf (Gregory)
    Member
    Posted 1 year ago #

    Hello,

    thanks for you reply.

    could you show me an exemple of code ?

    i did not know how to do this.

    best regards

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    to show upcoming events, you'd could do e.g.

    $events = EM_Events::get(array('limit'=>5));

    that'd give you an array of EM_Event objects which are essentially extended versions of the $post objects you'd get with get_posts() - http://codex.wordpress.org/Template_Tags/get_posts

  5. HimSelf (Gregory)
    Member
    Posted 1 year ago #

    ok, but how can i include this in my wp_query ?

    $slider = new WP_Query('post_type=event&orderby=event_start_date&order=DESC&showposts=5');

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    To use wp_query you'd need to do a custom field search.

    There are start/end timestamps stored as _start_ts and _end_ts

    http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

    I'm not sure you can do this with a querystring as you did, you'd need to supply your argument as an array.

  7. HimSelf (Gregory)
    Member
    Posted 1 year ago #

    its actually working thru wp-query but not in the good order and passed event still beeing displayed.

    i understand what you mean but sincerly i didnt know how to developp it.

    almost, when using the plugin we did not fill any custom field for event_start_date

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    you'd have to fill in _event_start_date but we add it for you, that's the datepicker where you choose your event start date. however the one you want is _start_ts as that's a timestamp which can be easily ordered.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic