今回も備忘録的に書き残しておきます。
公開済みの投稿を3件だけ表示させたくてググり倒した結果、見つけたのが以下のコード。
「WP_Query」で検索すると、色々と詳しい解説記事に出会えました。
<?php
$topnews = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3
);
?>
<?php $my_query = new WP_Query( $topnews ); ?>
<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>"><time><?php the_time('Y.n.j'); ?></time><p><?php the_title(); ?></p></a>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
Visited 59 times, 1 visit(s) today