Events Added to Main Loop; Loop Modified; Orderby Broken

Home Forums Calendar Products Events Calendar PRO Events Added to Main Loop; Loop Modified; Orderby Broken

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #268644
    Jamie
    Participant

    My site requires a hero banner on the home page that’s either populated by 1) a featured flag designated with a meta key or 2) the next upcoming event when the flag isn’t present. In both cases, I want the post to be removed from the main loop if it’s populating the hero banner.

    I’ve achieved adding events to my the main loop with pre_get_posts in functions.php.
    I’ve populated the banner for both cases with get_posts and some conditional statements.
    I’ve removed the flagged post from the loop through post__not_in argument with query_posts.
    The modified loop returns all of the posts I expect…

    HOWEVER
    WordPress is treating the EVENT START DATE on every tribe_events post type AS THE PUBLISHED DATE. This is very, very confusing. If I wanted this behavior, I would use tribe_get_events.

    Am I missing something or is the bug in forum thread below still not fixed?
    https://tri.be/support/forums/topic/wp_query-with-orderby-date-returns-an-ordering-based-on-the-events-start-date/

    I’ve been picking away at this hero functionality on and off for months now and I’m very close to solving it. Thanks in advance for any insight into this problem.

    #270234
    Barry
    Member

    Hi!

    WordPress is treating the EVENT START DATE on every tribe_events post type AS THE PUBLISHED DATE. This is very, very confusing. If I wanted this behavior, I would use tribe_get_events.

    So can you confirm what the ideal behaviour is in your case? We do deliberately have code in place to ensure that if events are integrated into the main blog loop they are ordered as you have described (this is intentional rather than being a bug).

    #271341
    Jamie
    Participant

    Ideal behavior is for the main loop to display the latest published news and event announcements so a visitor can skim the home page and not miss any news.

    #274118
    Barry
    Member

    OK. Could you try adding this short snippet to your theme’s functions.php file:

    add_action( 'pre_get_posts', 'reorder_events_in_blog', 100 );
    
    function reorder_events_in_blog( $query ) {
    	if ( isset( $query->tribe_is_multi_posttype ) )
    		unset( $query->tribe_is_multi_posttype );
    }

    Does that help at all?

    #279549
    Jamie
    Participant

    Success! Thanks for your prompt assistance!

    #283021
    Barry
    Member

    My pleasure – happy to help 🙂

    I’ll go ahead and close this thread since it sounds like you’re all sorted – of course if we can help with anything else please don’t hesitate to create new threads as needed and one of the team will be only too happy to assist.

    Last but not least, if you had a moment to spare we’d love to hear from you if you were able to leave a few words on our plugin review page – thanks again!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Events Added to Main Loop; Loop Modified; Orderby Broken’ is closed to new replies.