• Resolved delflux

    (@delflux)


    Hello –
    I’m trying to get each event in my event list featured on a SlideDeck2 slider. I was able to get it working by filtering the events via Tags in the slidedeck2 posts source.

    The only issue I’m having is that it sorts/displays events by the event date in descending order and would like it to sort in ascending order (whatever event is coming up next). Any idea how I would go about doing that? In slidedeck 2 it allows me to order posts by recent, popular, user sort order.

    http://wordpress.org/plugins/the-events-calendar/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter delflux

    (@delflux)

    They also have this code on their site which shows you how to do custom sorting for the slider:

    /**
     * Modify sort method for WordPress post based SlideDecks
     *
     * @param array $query_args The Array of query arguments passed to WP_Query
     *                          (http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters)
     * @param array $slidedeck The PHP Array that describes the SlideDeck being rendered
     *
     * @return array
     */
    function slidedeck_posts_slidedeck_query_args( $query_args, $slidedeck ) {
        // Check to see if the SlideDeck being rendered is ID 1451
        if( $slidedeck['id'] == 1451 ) {
            // Set the orderby value to use the "meta_value"
            $query_args['orderby'] = "meta_value";
            // Set the meta_key to use to "event_date", this should be the meta_key name you want to sort by
            $query_args['meta_key'] = "event_date";
            // The direction you wish to sort (ASC|DESC)
            $query_args['order'] = 'ASC';
        } 
    
        // Always return $query_args, even if you aren't modifying it or you will break things
        return $query_args;
    }
    // Hook into the slidedeck_posts_slidedeck_query_args filter and specify a priority of
    // 10 (default) and receiving 2 query arguments, so we get information about the SlideDeck
    add_filter( 'slidedeck_posts_slidedeck_query_args', 'slidedeck_posts_slidedeck_query_args', 10, 2 );

    I would like to know how to tie that code into the event Start Date on The Events Calendar.

    The meta key for the event start date is _EventStartDate and you may also need to specify the post type, which is tribe_events – does that help?

    Guessing you’re all sorted as it has been a while without a reply (and we can’t help too much more with customizations like this anyway) … if you have any other questions though please do feel free to create new threads as needed.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Event Sorting on SlideDeck 2’ is closed to new replies.