Posts are getting posted in the wrong order.

Home Forums Calendar Products Events Calendar PRO Posts are getting posted in the wrong order.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1015002
    Cynthia Lockley
    Participant

    My home page shows the calendar and the collection of posts from the blog and from the events. They are supposed to be displayed in the order written. I had this fixed a while ago so it was working with the latest calendar update, but as of .2 and .3 releases, the blog posts are showing up below all the upcoming event posts. Having the event posts take priority is not necessary–the upcoming events are listed in order in the sidebar widget. I need our recent news at the top. This is the code in my functions.php file in the child theme that used to do this for me:

    <?php
    //
    // *************************************
    // Events Calendar fix
    // Sort Events posts by creation date rather than start date
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    //add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’, 51 );
    //function tribe_post_date_ordering( $query ) {
    //if ( $query->tribe_is_multi_posttype) {
    //remove_filter( ‘posts_fields’, array( ‘Tribe__Events__Query’, ‘multi_type_posts_fields’ ) ); $query->set( //’order’, ‘DESC’ );
    //}
    //}
    add_action( ‘pre_get_posts’, ‘custom_teardown_tribe_order_filter’, 60 );
    function custom_teardown_tribe_order_filter() {
    if ( is_feed() ) remove_filter( ‘posts_orderby’, array( ‘Tribe__Events__Query’, ‘posts_orderby’ ), 10, 2 );
    }
    ?>

    What has changed again?

    Thanks.

    #1015066
    Geoff
    Member

    Hello Cynthia–nice to see you again and hope all is well. 🙂

    Quick question: have you tried uncommenting the first portion of that snippet you shared?

    In other words, that snippet would look like this:

    <?php
    //
    // *************************************
    // Events Calendar fix
    // Sort Events posts by creation date rather than start date
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’, 51 );
    function tribe_post_date_ordering( $query ) {
    if ( $query->tribe_is_multi_posttype) {
    remove_filter( ‘posts_fields’, array( ‘Tribe__Events__Query’, ‘multi_type_posts_fields’ ) ); $query->set( //’order’, ‘DESC’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘custom_teardown_tribe_order_filter’, 60 );
    function custom_teardown_tribe_order_filter() {
    if ( is_feed() ) remove_filter( ‘posts_orderby’, array( ‘Tribe__Events__Query’, ‘posts_orderby’ ), 10, 2 );
    }
    ?>

    Let’s start there and see if that does the trick. 🙂

    Thanks!
    Geoff

    #1015110
    Cynthia Lockley
    Participant

    Geoff,

    I copied your code above and replaced what I had in my functions.php file. Now I get a completely blank home page. 🙁

    #1015128
    Geoff
    Member

    Sorry! There was a formatting issue in there from the original snippet. Try this:

    function tribe_post_date_ordering( $query ) {
    if ( $query->tribe_is_multi_posttype) {
    remove_filter( 'posts_fields', array( 'Tribe__Events__Query', 'multi_type_posts_fields' ) ); $query->set( 'order', 'DESC' );
    }
    }
    add_action( 'pre_get_posts', 'custom_teardown_tribe_order_filter', 60 );
    function custom_teardown_tribe_order_filter() {
    if ( is_feed() ) remove_filter( 'posts_orderby', array( 'Tribe__Events__Query', 'posts_orderby' ), 10, 2 );
    }

    Thanks!
    Geoff

    #1015335
    Cynthia Lockley
    Participant

    Geoff,

    I did get the home page back. But that didn’t work for reordering the posts.

    I retried it by restoring the first action line above the first function, but that didn’t help either. So the code is now:
    <?php
    //
    // *************************************
    // Events Calendar fix
    // Sort Events posts by creation / published date rather than start date
    // from Geoff’s second code in ticket at
    // https://theeventscalendar.com/support/forums/topic/posts-are-getting-posted-in-the-wrong-order/
    // this just reorders future events–news post still at bottom
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’, 51 );

    function tribe_post_date_ordering( $query ) {
    if ( $query->tribe_is_multi_posttype) {
    remove_filter( ‘posts_fields’, array( ‘Tribe__Events__Query’, ‘multi_type_posts_fields’ ) ); $query->set( ‘order’, ‘DESC’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘custom_teardown_tribe_order_filter’, 60 );

    function custom_teardown_tribe_order_filter() {
    if ( is_feed() ) remove_filter( ‘posts_orderby’, array( ‘Tribe__Events__Query’, ‘posts_orderby’ ), 10, 2 );
    }
    ?>

    But that just orders all future events by date above all the current news posts.

    This is how it worked before: I want all posts listed in the order they were published regardless if they are an event or a news post. In other words if two future events will occur one to two weeks from now, I want then listed below the news post I just wrote yesterday. Sometimes the news posts are about one of those future events, or it is important that users see it right away and not have to scroll through future events to get to the current news posts.

    #1015342
    Geoff
    Member

    Hi Cynthia,

    Thanks for clarifying!

    Will this snippet work for you instead? Please let me know. 🙂

    Geoff

    #1015359
    Cynthia Lockley
    Participant

    That’s a strange one. it just listed all the post categories putting categories at the top for all posts published starting on 1 April 2007.

    Maybe I should have kept the previous reordering clips and just added this one to them?

    I’ll try that now.

    #1015367
    Cynthia Lockley
    Participant

    Nope. Still getting just the categories from 2007 listed on the home page in a very different font. Also, when I try the Older posts link at the bottom of the list of categories, it continues with more categories from April 2007 but the month calendar is blank. Going back restores the October events in the month view.

    The November link below the calendar works correctly.

    See http://events.stcwdc.org/

    #1015406
    Cynthia Lockley
    Participant

    I updated to the .4 release that was just put out and now, no matter which version of the post ordering code I put in the functions.php file, the home page says:
    Nothing Found
    Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.

    No calendar, no events, no news posts.

    #1015422
    Cynthia Lockley
    Participant

    Geoff,

    See my comments in https://theeventscalendar.com/support/forums/topic/latest-4-release-has-no-results-found-on-home-page/
    After unchecking the “Recurring event instances” that somehow had gotten rechecked, the functions are now working again as desired. Now I’m not sure if the code in the full function is all necessary. Here is what I have that now works with the Recurring event instances unchecked:

    <?php
    //
    // *************************************
    // Events Calendar fix
    // Sort Events posts by creation / published date rather than start date
    // from Geoff’s second code in ticket at
    // https://theeventscalendar.com/support/forums/topic/posts-are-getting-posted-in-the-wrong-order/
    // this just reorders future events–news post still at bottom
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //

    add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’, 51 );

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

    add_action( ‘pre_get_posts’, ‘custom_teardown_tribe_order_filter’, 60 );

    function custom_teardown_tribe_order_filter() {
    if ( is_feed() ) remove_filter( ‘posts_orderby’, array( ‘Tribe__Events__Query’, ‘posts_orderby’ ), 10, 2 );
    }

    add_action( ‘pre_get_posts’, ‘order_by_modified’ );
    function order_by_modified( $query ) {

    if ( $query->is_home() && $query->is_main_query() ) {

    $query->set( ‘orderby’, ‘modified’ );
    }
    }
    ?>

    #1015442
    Geoff
    Member

    Whoa, nice update! Sounds like everything got ironed out between here and the thread you have open with Brian. Is that correct? Let me know if there’s anything else here you still need us to look into.

    Thanks!’
    Geoff

    #1015512
    Cynthia Lockley
    Participant

    Well, the code in the functions.php now work as long as the “Recurring events instances” remains unchecked in the settings.

    Brian had said work was going on to find out why and that the next releases would contain the fix. But they seemed to have turned the “Recurring events instances” back on and broke the modification functions. Are there still plans to work on how the recurring events instances affects the modification functions? Or is that part settled–keep that unchecked?

    #1016172
    Geoff
    Member

    Hello Cynthia,

    Looks like Brian already beat me to the punch and answered your question here. In short, that is indeed an issue and we are looking into it. Brian recommends downgrading to 3.11 for the time being and that sounds right to me as well.

    Sorry for the hassle here but thanks for bearing with us and letting us know!

    Geoff

    #1021642
    Support Droid
    Keymaster

    This 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.

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Posts are getting posted in the wrong order.’ is closed to new replies.