Integrate events with main blog – control # and order

Home Forums Calendar Products Community Events Integrate events with main blog – control # and order

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1025430
    barback
    Participant

    I’ve turned on the option to “Include events in main blog loop” – but it includes ALL of my events, including ones that have gone by, and it orders them to list the farthest out event first and the farthest past event last.

    What I’d LIKE is to feature only the next UPCOMING THREE events in my main blog loop.

    #1026350
    George
    Participant

    Hey @barback,

    Thanks for reaching out – I’m sorry to bear this news, but what you described is essentially the default way the “Include events in main blog loop” option works. Altering this to only include the next 3 upcoming events is a bit tricky and would require writing custom code 🙁

    The customization of this outright is a bit too complex for full code support here on the forums, but if you’re keen on enabling this limitation on your site, you can find the relevant code by going to this file in your The Events Calendar plugin files: src/Tribe/Query.php

    Around line 158 you’ll find the relevant code. With this file and/or the action tribe_events_pre_get_posts() you can customize the query output. You’ll need some familiarity with WordPress’ own pre_get_posts() function, which you can learn about here if you’re not familiar with it → https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    I hope this information helps!

    — George

    #1026966
    barback
    Participant

    Thanks George for pointing me in the right direction.

    I’m a bit surprised that The Events Calendar offers this option as is, because I can’t imagine who would want to promote their most distant event at the top of their blog, leaving current or soon to happen events buried in the midst.

    If the events posted in order of their creation or publication, vs. the order of the event’s date, I would have some more control and could force the ones I want to feature to the surface. As it is, I will have to do the custom coding you suggest, or abandon your “feature” and create duplicate content in the form of posts.

    Anybody have any other ideas?

    #1027684
    George
    Participant

    Hey @Barback,

    To be clear, the most-distant event should only really be displaying before more recent events if other plugins or your theme are also manipulating the main Queries on your site.

    The tribe_events_pre_get_posts() function I wrote about above may indeed be a way out of these issues. If you are not comfortable with editing code, your best bet is to hire a professional. We have a list of some highly-rated ones here, just in case it’s helpful → http://m.tri.be/18k1

    I’m sorry about these limitations 🙁 I will close up this thread for now but wish you the best of luck with your site.

    Sincerely,
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Integrate events with main blog – control # and order’ is closed to new replies.