Home › Forums › Calendar Products › Community Events › order of events: showing events by post date
- This topic has 24 replies, 4 voices, and was last updated 8 years, 1 month ago by Support Droid.
-
AuthorPosts
-
February 17, 2016 at 2:37 pm #1074678JoshParticipant
Hey Marion,
I apologize for the delay here and I appreciate your patience.
I hit a wall trying to get this to work from a bunch of different perspectives. Like Edison, I found a bunch of ways that failed but eventually, with the help from others on our team, I found the orderby post date “bamboo”.
The issue here came down to a recently modified function and forcing all “tribe_events” queries to use the event date for ordering no matter watch you may have set or filtered it to be.
To get this to work though, would be to modify your current approach slightly. Rather than redirect to the default list view (since there is a lot more going on there than just an events query) it would be best to do a new custom “tribe_events_query” using the following args:
$args = array( 'suppress_filters' => true, 'post_type' => 'tribe_events', 'orderby' => 'date', 'order' => 'DESC' );
From there, you can do a foreach loop on the returned array and apply your Masonry code to that loop there.
Let me know if this helps.
Thanks!
February 18, 2016 at 6:57 am #1075074MarionParticipantHi Josh.
thank you so much for your research and new solution! I will get into it by tomorrow and let you know if it works!
Marion
February 19, 2016 at 10:31 am #1078353JoshParticipantHey Marion,
No problem! Let me know how it turns out.
Thanks!
February 26, 2016 at 12:12 pm #1082680MarionParticipantHi Josh,
this is my new code:
<?php global $post; $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; $all_events = tribe_get_events(array( 'suppress_filters' => true, 'post_type' => 'tribe_events', 'order' => 'DESC', 'posts_per_page' => 30, 'paged' => $paged, 'page' => $paged )); foreach($all_events as $post) { setup_postdata($post); ?> <!-- the loop --> <article class="grid-item"> ... <a href="<?php echo esc_url( tribe_get_event_link() ); ?>" class="tribe-events-read-more" rel="bookmark"><?php esc_html_e( 'Find out more', 'the-events-calendar' ) ?> ⟩</a> </article> <!-- end of the loop --> <?php } //endforeach ?> <?php wp_reset_query(); ?>
Is it the way you were talking about?
And I think it its working like I want, still have to to some testing.But ( I am sorry, that there is another but): is it possible only to query the future events?
Have a nice weekend
MarionFebruary 29, 2016 at 7:10 pm #1083664JoshParticipantHey Marion,
That looks like it should work! Also, to have it show only the upcoming, you can add “eventDisplay => ‘upcoming'” to the args there.
Let me know if this helps.
Thanks!
March 1, 2016 at 1:48 am #1083766MarionParticipantHi Josh,
unfortunately this does not work:
<?php global $post; $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; $all_events = tribe_get_events(array( 'eventDisplay'=>'upcoming', 'suppress_filters' => true, 'post_type' => 'tribe_events', 'order' => 'DESC', 'posts_per_page' => 30, 'paged' => $paged, 'page' => $paged )); foreach($all_events as $post) { setup_postdata($post); ?> <!-- the loop -->
When I erase ‘suppress_filters’ => true it works, but then again the order is not the way I want it to be (by post date not event date).
I really like to solve this, any more ideas?
Kind regards Marion
March 2, 2016 at 5:55 am #1084260JoshParticipantHey Marion,
Hmm, you’re right. I didn’t consider that but if we are suppressing filters then it is unlikely that any of our args for the query would continue to work such as the eventDisplay one.
The alternative would be to do a check just inside your foreach loop between the current date and the event start date. If the event start date is greater than the current date then display the event.
Let me know if this helps.
Thanks!
March 2, 2016 at 9:14 am #1084437MarionParticipant.. it seemed actually just an easy request and it turned out to be so tricky đŸ˜‰
Do you have a kind of an example link/snippet? That would be great…
Thank you Josh,
MarionMarch 4, 2016 at 9:48 pm #1085452JoshParticipantHey Marion,
I don’t currently have a snippet on hand. When adding to your template though, you’ll use the Date link above to get the current date and you can use “tribe_get_start_date” for the event date. The comparison would then be a normal “if” statement (if( $start_date > $date)).
Thanks!
March 19, 2016 at 9:35 am #1091396Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘order of events: showing events by post date’ is closed to new replies.