Posts should appear in descending chronological order. No plugin should be needed for that.
Sorry Steve, I should have been more clear. I need them to be ascending order.
Use a callback function for pre_get_posts to change the sort order from DESC to ASC. That will change them from newest first to oldest first.
https://codex.ww.wp.xz.cn/Plugin_API/Action_Reference/pre_get_posts
Thanks for getting back to me, Steve. I’m not exactly clear on what I need to do… would you be able to be more specific about the PHP code needed?
This is NOT tested code — you need to do SOMETHING LIKE this….
add_action( 'pre_get_posts', 'reverse_post_order' );
function reverse_post_order( $query ) {
if ( is_main_query() && is_archive() ) { // this is the conditional you have to work on
$query->set( 'order', 'ASC');
}
}
see https://codex.ww.wp.xz.cn/Conditional_Tags
Thank you so much, Steve. I’m sorry to take up more of your time but I’ve tested this code and I’m still not getting the results I’m looking for… this code is placed in my child theme’s function.php file:
/*===================================================================*/
/* 4. CHRONOLOGICAL ORDER
/*===================================================================*/
add_action( ‘pre_get_posts’, ‘reverse_post_order’ );
function reverse_post_order( $query ) {
if ( is_main_query() && is_front_page() && is_home() ) {
$query->set( ‘order’, ‘ASC’);
}
}
I don’t need the archive to be in chronological order, so I removed that condition and added that I need the homepage/blog page in chronological order. Using that code, it’s still in descending order. Any idea why it’s not working?
Because that makes no sense. What order do you want the posts to be in?
How is your home page content set?
Thanks again for your help, Steve. I’m going to pause on this until tomorrow as the “Chronological Posts” plugin author has provided me with a solution to fix the RSS feed issue that I’m hoping will work and I won’t need to fiddle with this code. I’ll be in touch tomorrow and if all works I’ll mark this discussion as resolved. Thanks again for your support so far.
The “Chronological Posts” plugin author has provided me with a solution to fix the RSS feed issue and so I’ve marked this discussion as resolved. Thanks again for your time and help, Steve.