【WordPress】スマホ表示時だけ記事一覧の表示件数を変更する方法(pre_get_posts)

公開 更新 読了 1分
test
function mobile_posts_per_page( $query ) {
  if ( ! is_admin() && is_mobile() && $query->is_main_query() ) {
      $query->set( 'posts_per_page', 10 ); //10件表示
  }
}
add_action( 'pre_get_posts', 'mobile_posts_per_page' );