We're merging with GenerateBlocks! Learn more here.

[Support request] Sort by Event Date

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Sort by Event Date

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

    I have event listings and I am using the Geodirectory plugin. I want to order the events by the date the event is being held, with the nearest upcoming event being shown first.

    Geodirectory use event_dates_asc for this kind of query.

    So, I have used the following shortcode:

    [wp_show_posts id="14475" settings="orderby=event_dates_asc"]

    However, it is not working.

    I have debugged to make sure the query is being pulled in, which it is:

    array(5) { ["order"]=> string(4) "desc" ["orderby"]=> string(15) "event_dates_asc" ["post_type"]=> string(8) "gd_event" ["posts_per_page"]=> int(10) ["post_status"]=> array(1) { [0]=> string(7) "publish" } }

    I am just wondering whether there is something I am missing.

    Thanks, Gary


    Hi Gary,

    You can add this code based from the previous topic you’ve replied on.

    /* Sort Events by Ascending as a Default */
    function order_events_by_next_start_date( $wp_query ) {
      if (is_admin()) {
        $post_type = $wp_query->query['post_type'];
        if ( $post_type == 'gd_event') {
          $wp_query->set('orderby', 'event_dates_asc');
          $wp_query->set('order', 'ASC');
    add_filter('pre_get_posts', 'order_events_by_next_start_date');

    Or, add &order=ASC to the settings used in your shortcode:
    [wp_show_posts id="14475" settings="orderby=event_dates_asc&order=ASC"]

    Mind the text case/capitalization.

    Let us know if it works for you.


    Sadly, this isn’t working for me. But no problem. I will work with what I’ve got within Geodirectory for now. I’ll revisit this at a later date as I prefer the configuration/styling options of WPSP. Thanks Elvin. Best, Gary


    Let us know if you have any other issues that needs addressing. No problem.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.