order of events: showing events by post date

Home Forums Calendar Products Community Events order of events: showing events by post date

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #1057609
    Marion
    Participant

    Hi there,

    is it possible to show the events ordered by date of publishing and not by the events actual date?

    I searched the topics and found this snippet:
    add_action( 'pre_get_posts', 'tribe_post_date_ordering', 51 );

    function tribe_post_date_ordering( $query ) {
    if ( ! empty( $query->tribe_is_multi_posttype ) ) {
    remove_filter( 'posts_fields', array( 'Tribe__Events__Query', 'multi_type_posts_fields' ) );
    $query->set( 'order', 'DESC' );
    }
    }

    BUT I am using a customized (masonry) template for showing the events in list view and it would be great if it would be possible to change the order using this template.

    I don’t like to change everything to make it work by showing the events in the order by post-date using the blog-function/showing the events like posts by showing the latests entries…

    Kind regards
    Marion

    #1058258
    Josh
    Participant

    Hey Marion,

    Thanks for reaching out to us!

    The code above should work no matter what the template is since it just modifies what posts are pulled and how they’re fed into your template. However, this is dependent on the template being built using the main query. If you’re template pulls from a custom query, you can add the pre_get_posts on that query to get the events the way that you would like.

    Let me know if this helps.

    Thanks!

    #1058723
    Marion
    Participant

    Hi Josh,

    thanks for your reply. But I am doing something wrong, I think…

    I try to explain it more:

    -> Frontpage: in WP Settings its set to Static Page

    -> Show Events with Blog posts: checked or unchecked? / actually I am not having extra Posts, only the Event-Posts submitted by the user, so this can be unchecked?

    -> Code Snippet from above: its (at the moment) at the end of my child themes function.php

    -> Template: maybe this was misleading, I am using the default template from the plugin,
    I changed the layout including a masonry script… but as far as I know, I did not change the query or loop, and so the installed theme is not in “charge”, because I am “just” using a modified version of the events calendar default template? mhmmh…

    Looking forward to your opinion…

    Kind regards
    Marion

    #1059590
    Josh
    Participant

    Hey Marion,

    Thanks for clarifying here.

    I did a little research and I believe we need the original snippet to be modified to include a change on the eventDisplay there.

    
    function tribe_post_date_ordering( $query ) {
    if ( ! empty( $query->tribe_is_multi_posttype ) ) {
    remove_filter( 'posts_fields', array( 'Tribe__Events__Query', 'multi_type_posts_fields' ) );
    $query->set( 'order', 'DESC' );
    $query->set( 'eventDisplay', 'custom' );
    }
    }
    

    Let me know if this helps in your case here.

    Thanks!

    #1062863
    Marion
    Participant

    Hi Josh,

    thank you for checking this out, but unfortunately it does not work, meaning: it does nothing, actually the behavior of the website is not affected at all, but maybe I am putting it in the wrong position and it does not take any effect?

    Do you have maybe more thoughts on this?

    Thanks for letting me know…

    Marion

    #1063989
    Geoff
    Member

    Hi Marion, just stepping in for Josh while he’s out.

    Are you placing the snippet in your functions.php file? If so, is it in your primary theme or the child theme file you mentioned earlier?

    Thanks!
    Geoff

    #1064203
    Marion
    Participant

    Hi Geoff,

    thanks for stepping in 🙂

    The snippet is at the end of my child-themes functions.php

    Marion

    #1064204
    Marion
    Participant

    This reply is private.

    #1065731
    Josh
    Participant

    Hey Marion,

    Thanks for providing the functions file info here.

    You’ll need to add “add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’);” right above the function added at the end of the file. This allows it to hook into that main query and let the settings you’re adding there to take impact.

    Let me know if this helps.

    Thanks!

    #1067117
    Marion
    Participant

    Hi Josh,

    aah, yes, but unfortunately in this case: no :/ still does not react.

    Do you want me to explain it again more detailed?

    The website has no blog-posts at all, just the events listing from the plugin.

    I have a permanent redirection from the home to the …/events subpage, but I think this has nothing to do with my problem?

    M.

    #1068362
    Josh
    Participant

    Hey Marion,

    Thanks for following up with us. Ah! the previous snippet won’t work for this type of set up I don’t believe then. Will do some testing on an alternative snippet and will follow up with you here.

    Thanks!

    #1068482
    Marion
    Participant

    Hi Josh,

    thanks again for your answer, I am looking forward to your new idea 🙂

    Marion

    #1070902
    Josh
    Participant

    Hey Marion,

    Sorry for the delay here. Just noticed a comment above that would change the approach here. The display that you are wanting to change the order for is the default list view for the plugin?

    Thanks!

    #1071629
    Marion
    Participant

    Hi Josh,

    yes, the default view is the list view, (I have enabled list and day view).

    The Layout of the site is a masonry-style-grid, I added a script for making this happen.

    So, the thing is, that the website is more like a news-board than an event-calendar. Its important for the users to see at the beginning of the site (grid), if there are new posts.
    At the moment, the new ones are at the bottom of the website, and in case a user does not notice, one might think “oh, there are no new posts, I will quit looking around..”.

    Thats why the date of posting is so important and not the date/period of the posted event.

    I think, it does not have to be just a reverse order, because there may be posts, that are posted today and will take place tomorrow or will take place in 3 weeks, either/or the post should be at the very beginning of the site, because it is posted today.

    Does this make sense to you?

    Marion

    #1073572
    Marion
    Participant

    Hi Josh,

    sorry for being a bit pushy, but do you already know something new?

    Marion

Viewing 15 posts - 1 through 15 (of 25 total)
  • The topic ‘order of events: showing events by post date’ is closed to new replies.