Change the default loop with function.php

Marko Krstić
10 Sep 2020
/*==========================================
=            Reverce loop order            =
==========================================*/
function alter_order_of_posts( $query ) {
    if ( $query->is_main_query() ) {
        $query->set( 'order', 'ASC' );
        $query->set( 'orderby', 'menu_order' );
    }
}
add_action( 'pre_get_posts', 'alter_order_of_posts' );

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy