WordPressの記事一覧を取得する方法

最終更新日

1.記事タイトルを取得
2.記事のパーマリンクを取得
3.記事本文を取得
4.投稿日を取得
5.投稿時間を取得
6.記事が属してるカテゴリーを取得

<div id="content">
<?php if(have_posts()): while (have_posts()):the_post(); ?>
<div class="post">
  <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  <?php the_excerpt(); ?>
  <p class="postinfo">
  <?php echo get_the_date(); ?><?php the_time(); ?>|カテゴリー:<?php the_category(' , '); ?>
  </p>       
</div>
<?php endwhile; endif; ?>
<div>

<!–more–>を毎回つけるが面倒な場合はthe_content()を、the_excerpt()に切り替えて記述するだけで抜粋できるようです。