Home › Forums › Calendar Products › Events Calendar PRO › Events Added to Main Loop; Loop Modified; Orderby Broken
- This topic has 5 replies, 2 voices, and was last updated 9 years, 9 months ago by Barry.
-
AuthorPosts
-
July 2, 2014 at 6:05 pm #268644JamieParticipant
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.
July 3, 2014 at 2:59 am #270234BarryMemberHi!
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).
July 3, 2014 at 9:07 am #271341JamieParticipantIdeal 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.
July 3, 2014 at 10:39 pm #274118BarryMemberOK. 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?
July 4, 2014 at 11:12 am #279549JamieParticipantSuccess! Thanks for your prompt assistance!
July 4, 2014 at 10:17 pm #283021BarryMemberMy 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!
-
AuthorPosts
- The topic ‘Events Added to Main Loop; Loop Modified; Orderby Broken’ is closed to new replies.