【WordPress】記事一覧の取得方法(その4)
書き方メモ。
sample
<div class="記事最新5件ですよ">
<h3><a href="アーカイブページへのリンク">見出しですよ</a></h3>
<?php query_posts('showposts=5');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="xxxxxxxx">
<h3><?php the_time ('Y年n月j日'); ?> <a href="<?php the_permalink (); ?>"><?php the_title (); ?></a></h3>
<div><?php the_excerpt(); ?></div>
<p><a href="<?php the_permalink (); ?>">続きを見る</a></p>
</div>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</div>
query_postsするとメインのWordPressループが変更される。
wp_reset_queryすると、メインのWordPressループを前のものに戻すことができる。