Home › Forums › Calendar Products › Events Calendar PRO › Posts are getting posted in the wrong order.
- This topic has 13 replies, 3 voices, and was last updated 8 years, 6 months ago by Support Droid.
-
AuthorPosts
-
October 15, 2015 at 10:02 am #1015002Cynthia LockleyParticipant
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.
October 15, 2015 at 1:34 pm #1015066GeoffMemberHello 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!
GeoffOctober 15, 2015 at 3:45 pm #1015110Cynthia LockleyParticipantGeoff,
I copied your code above and replaced what I had in my functions.php file. Now I get a completely blank home page. 🙁
October 15, 2015 at 4:41 pm #1015128GeoffMemberSorry! 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!
GeoffOctober 16, 2015 at 9:38 am #1015335Cynthia LockleyParticipantGeoff,
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.
October 16, 2015 at 9:49 am #1015342GeoffMemberHi Cynthia,
Thanks for clarifying!
Will this snippet work for you instead? Please let me know. 🙂
Geoff
October 16, 2015 at 10:22 am #1015359Cynthia LockleyParticipantThat’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.
October 16, 2015 at 10:35 am #1015367Cynthia LockleyParticipantNope. 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.
October 16, 2015 at 12:59 pm #1015406Cynthia LockleyParticipantI 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.
October 16, 2015 at 1:33 pm #1015422Cynthia LockleyParticipantGeoff,
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’ );
}
}
?>October 16, 2015 at 2:25 pm #1015442GeoffMemberWhoa, 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!’
GeoffOctober 16, 2015 at 11:30 pm #1015512Cynthia LockleyParticipantWell, 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?
October 20, 2015 at 6:41 am #1016172GeoffMemberHello 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
November 4, 2015 at 6:05 am #1021642Support 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 ‘Posts are getting posted in the wrong order.’ is closed to new replies.