query_postsで設定したループ条件をリセットする

Filed under: wordpress — kdcs @ 12年9月10日 月曜日

query_postsでループ条件を設定すると、以降のループはすべて同一条件で表示します。
そのページ全体が設定した条件になってしまう。

このループ条件をリセットする記述

<?php wp_reset_query(); ?>

ループエンドに記述してもよい(例:カテゴリー5 表示記事数20)

<?php query_posts('cat=5&showposts=20');
if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php endwhile; endif; wp_reset_query(); ?>

サイト内検索

カテゴリー

最近の投稿

« |query_postsで設定したループ条件をリセットする| »
↑上に戻る