Codex

Function Reference/wp reset query

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.

Contents

Description

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.

Usage

<?php wp_reset_query(); ?>

Parameters

This function does not accept any parameters.

Return Values

This function does not return any values.

Examples

The following example shows how to use wp_reset_query() after a custom loop
<?php query_posts('showposts=5'); ?>
<?php 
if (have_posts()) : while (have_posts()) : the_post(); ?>
    <a href=\"<?php the_permalink() ?>\"><?php the_title() ?></a><br />
<?php endwhile; endif; ?>
<?php wp_reset_query
(); ?>

Change Log

Since: 2.3.0

Source File

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

Related

See also index of Function Reference and index of Template Tags.