2011年10月7日金曜日

(wordpress)記事を繰り返す記述

query postsを利用したループ。

(例)  
<?php if (have_posts()) :  query_posts('posts_per_page=5&cat=10');  ?>
<?php while (have_posts()) : the_post(); ?>
<div class="">
<?php the_title(); ?><!--タイトルを取得-->
<?php the_content(); ?><!--本文を取得-->
<?php the_time('Y年n月j日') ?><!--投稿の年月日を取得-->
<a href="<?php the_permalink() ?>">詳細を見る</a><!--パーマリンクを取得-->
</div>
<?php endwhile; endif; ?>

(参考URL)
・公式サイト
http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/query_posts

・スグラボさんのblog
http://blog.sugulab.com/?p=690

0 件のコメント: