通常のnew WP_Query内にpost_per_pageで取得するpost数を指定してもダッシュボード>設定>表示設定で指定した表示数になってしまうので以下の記述で対応。
<?php
$query = new WP_Query(
$args = array(
'post_type' => 'post',
'post_per_page' => 3,
)
);
$query->post_count = 3;
if ( $query->post_count > count( $query->posts ) ) :
$query->post_count = count( $query->posts );
endif; ?>
<?php if($query -> have_posts()): while($query -> have_posts()): $query -> the_post(); ?>
// ループさせる内容
<?php else : ?>
// 記事が無い場合の記述
<?php endif; wp_reset_postdata(); ?>