投稿の並び順を変更する方法メインループのクエリ条件を変更するには、pre_get_postsというアクションフックを利用します。このライブラリで説明している通り、query_posts()は使用してはいけません。 function twpp_change_sort_order( $query ) { if ( is_admin() || ! $query->is_main_query() ) { return; } if ( $query->is_home() ) { $query->set( 'order', 'ASC' ); $query->set( 'orderby', 'title' ); } } add_action( 'pre_get_posts', 'twpp_change_sort_order' );並び順を変更するには、クエリの順序付けパラメータを変更します。7行目で順序
![メインループにおける投稿の並び順を、タイトル・更新日・ランダムなど自由自在に変更する](https://cdn-ak-scissors.b.st-hatena.com/image/square/2a0c8dc341593490553872cee0bca6dae5e57db0/height=288;version=1;width=512/https%3A%2F%2Fthewppress.com%2Fwp-content%2Fuploads%2F2017%2F11%2Fscreenshot.png)