更新 2021 / 2 / 25
最新の1記事は大きく掲載し、2記事目から通常に一覧表示
まず最初のループで大きく表示したい記事を取得し、
posts_per_pageで1記事目を除外しています。全てを取得する場合は0を指定
参考:https://xtra-blog.net/new_post_layout/
archive.phpなど
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
$my_query = new WP_Query($args);
$first_post = $my_query-> posts[0];
$first_post_id = $first_post-> ID;
?>
<?php if( have_posts() ) : while(have_posts()) : the_post(); if($post->ID == $first_post_id): ?>
<!--1記事目-->
<?php else : ?>
<!--2記事目からここで表示-->
<?php endif; endwhile; endif; ?>