Jan
asked 1 month ago

How can I change the post order from asc to desc
 
Thx, Jan 🙂

1 Answers
DominicStaff
answered 1 month ago

You can use the following code into the functions.php file:

function foo_modify_query_order( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
    }
}
add_action( 'pre_get_posts', 'foo_modify_query_order' );
Powered by DW Question & Answer Pro