wp_reset_query

Sponsored Link

wp_reset_queryの関数は、カスタムループで使用された前のクエリーを廃止します。ループは、期待された条件付きタグの動作確認後に呼び出されるべきです。

Sponsored Link

This function destroys the previous query used on a custom Loop. Function should be called after The Loop to ensure conditional tags work as expected.

wp_reset_queryのテンプレートタグ使用方法

<?php wp_reset_query(); ?>

wp_reset_queryのパラメーター

この関数は任意のパラメータを受け付けません。

This function does not accept any parameters.

返り値

この関数は任意の値を返すことはありません。

This function does not return any values.

次の例では、カスタムループ後にwp_reset_query()を使用する方法で表示します。

The following example shows how to use wp_reset_query() after a custom loop

<?php 
query_posts('showposts=5');
if (have_posts()) : while (have_posts()) : the_post();
	?><a href="<?php the_permalink() ?>"><?php the_title() ?></a><br /><?php
endwhile; endif;
wp_reset_query();
?>

変更ログ

Since: 2.3.0

ソースファイル

wp_reset_query()は、located in wp-includes/query.php内に位置しています。

wp_reset_query() is located in wp-includes/query.php.

関連テンプレートタグ

get_posts, query_posts, rewind_posts, wp_reset_query

Sponsored Link