WordPress 特定のカテゴリーページを特定件数出したい

2010.12.04

query_post

カテゴリ名「message」という記事の最新3件をリスト表示する場合

<?php query_posts('&posts_per_page=3&category_name=message&order=DESC'); ?><!-- DESCは一番新しい記事が上に表示される(逆はASC) -->
 <?php if (have_posts()) : ?>
 <h3>お知らせ</h3>
 <ul>
 <?php while (have_posts()) : the_post(); ?>
 <li>
 <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a><!-- タイトルをリスト表示 -->
 </li>
 <?php endwhile; endif; ?>
 <?php wp_reset_query();?>

参考

http://www.bizmemowp.com/wordpress-biz272

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">