Show tagged events in event date order

Home Forums Calendar Products Events Calendar PRO Show tagged events in event date order

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1301678
    David
    Participant

    This is a follow-on from the topic at https://theeventscalendar.com/support/forums/topic/show-tag-events-in-date-order/ since further investigation suggests that the response misunderstood my question.

    We have a number of tagged events which we would like to share as a programme.

    When these are displayed on the website — see http://ramsgatefestival.org/tag/ramsgate-reflections/ — they appear in reverse order of the event dates: the latest event appears first, the first event appears last.

    The issue is not about publication date; it’s about event date. We would like the event on the earliest date to appear first and event on the latest date to appear last, as you would normally have in an event calendar.

    Is there any way to do this, please?

    #1302631
    Victor
    Member

    Hi David!

    Thanks for reaching out to us! Let me help you with that.

    First off, I do want to note that we are fairly limited in how much we can support custom development questions like this. That said, I’d be happy to at least point you in the right direction as best I can.

    You can change the order in which events show up in the tags archive page by customizing the query with the following code snippet:

    add_action( 'pre_get_posts', 'custom_tag_order' );
    function custom_tag_order($query) {
       if ( $query->is_main_query() && is_tag() ) {
          $query->set('orderby', 'meta_value');
          $query->set('order', 'ASC');
          $query->set('meta_key', '_eventStartDate');
          return $query;
       }
    }

    You should place this code in your theme’s functions.php file and it will order your events by their start date, starting from the earliest.

    I hope that helps! Let me know if you have other questions.

    Best,
    Victor

    #1321741
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Show tagged events in event date order’ is closed to new replies.