Listing of Events on the front page from the soonest to the latest

Home Forums Welcome! Pre-Sales Questions Listing of Events on the front page from the soonest to the latest

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1126034
    Levon
    Participant

    Hello,
    I am working with Events Calendar and the events on the front page are listed by date – starting from the latest date and moving into the earlier ones, also including the past ones.

    How can I change the settings so that we’ll see the soonest upcoming events and continue with events later by date?
    We don’t really need to post the past events as well..

    Thank you in advance,
    Nijen
    http://www.newhumancity.com

    #1126326
    Andras
    Keymaster

    Hi Nijen,

    Thanks for reaching out and welcome to the forums!

    I can try to help out here, but I am limited in supporting customizations. Per our terms and conditions we support features of the plugins and although we try to help get you started on customizations for the most part you are going to have to take it on to complete.

    I take it you are talking about your home page. Also, can you confirm that under Events > Settings > Include events in main blog loop is checked?

    So, on your home page your blog posts are listed, and if the above mentioned checkbox is checked, then your events will be listed there as well. By default the blog posts are listed in a reverse order (so the newest is always on top) and all old blog posts are shown.

    So first you would need to change the order of how your blog posts are displayed. You can find several plugins that should be able to help you, try this link for example, to get a list of them.

    The second you need to do is to hide past events. This is a bit trickier, please give me some time to check if it possible to do.

    As an alternative you could try the Photo view which is available in our Events Calendar Pro plugin. That could give you a similar look as your current Home and would only show future events in chronological order.

    Let me know if any of this helps.

    Cheers,
    Andras

    #1126348
    Andras
    Keymaster

    Hello again Nijen,

    A colleague of mine was nice enough to cook up the below snippet. If you copy that code to your theme’s (preferably child theme) function.php file, then it should only list future events on your Home.
    /**
    * Hide past events from the main blog loop, where events integration is enabled.
    *
    * Purely an example, may need some adjustment/tweaking depending on what other
    * components might also be acting on the query object.
    */
    add_action( 'tribe_events_pre_get_posts', function( WP_Query $query ) {
    if ( ! tribe_get_option( 'showEventsInMainLoop', false ) )
    return;

    if ( ! property_exists( $query, 'tribe_is_multi_posttype' ) || ! $query->tribe_is_multi_posttype )
    return;

    // Request posts with an unexpired Event End Date (ie, upcoming events) *or*
    // posts with no Event End Date at all (ie, normal posts)
    $upcoming_events_query = array(
    'relation' => 'OR',
    array(
    'relation' => 'AND',
    array(
    'key' => '_EventEndDate',
    'compare' => 'EXISTS',
    ),
    array(
    'key' => '_EventEndDate',
    'value' => current_time( 'mysql' ),
    'compare' => '>',
    ),
    ),
    array(
    'key' => '_EventEndDate',
    'compare' => 'NOT EXISTS',
    ),
    );

    // Check for an existing meta query
    $existing_meta_query = $query->get( 'meta_query' );

    // Set or merge - may need tweaking according to local conditions
    if ( $existing_meta_query) $meta_query = array_merge( $upcoming_events_query, $existing_meta_query );
    else $meta_query = $upcoming_events_query;

    $query->set( 'meta_query', $meta_query );
    } );

    Let me know if it helps.

    Cheers,
    Andras

    #1126984
    Levon
    Participant

    Thank you very much Andras!
    The code works! Send my gratitude to your colleague as well!

    I can’t find a pluging that actually changes order of the events by date though..
    Will keep looking..
    If you know about any specific please let me know…

    Thanks again

    #1127283
    Andras
    Keymaster

    Hi Nijen,

    Great, glad it helps. I’ll forward the kudos to the brain responsible. 🙂

    As for the order, you can try searching in the wordpress.org plugin repo, there are quite a number of them dealing with post order. And although I didn’t try it, this might be a good one.

    It could be also done without a plugin. You would need to modify the template that handles the WP loop. There’s some nice documentation on .org on how this could be done.

    Let me know if you have any follow up questions.

    Cheers,
    Andras

    PS: In case you are happy with Modern Tribe’s products and support, we would be really happy if you could leave us a review. Thanks!

    #1127573
    Levon
    Participant

    Thank you Andras!
    Looks like everything is working now…
    Thank you,
    Levon Nijen

    #1127881
    Andras
    Keymaster

    Great, glad it helps!

    I am going to go ahead and close this ticket, but if you need help on this or something else please post a new one. We’ll be here to help you out.

    Cheers,

    PS: If you like our plugin, we would be happy to receive a review in the wordpress.org repository. Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Listing of Events on the front page from the soonest to the latest’ is closed to new replies.