I thought I have solved it, but I have partly figured it out. When the page loads the first time, all posts are displayed alphabetically, but when I click on a category, not any more.
If I click “Show All” after clicking category, posts are not displayed alphabetically either. This is the code I used:
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’ );