wp_reset_query() rinizializza il valore di $wp_query al valore global del post prima della query . Gli sviluppatori di WordPress incoraggiono il suo utilizzo insieme alla funzione pre_get_post.
Il suo utilizzo è il seguente
<?php wp_reset_query(); ?>
Non accetta parametri e non ritorna alcun valore.
Esempio wp_reset_query() <?php $args = array ( 'post_parent' => 5 ); query_posts( $args ); if ( have_posts() ): while ( have_posts() ) : the_post(); // Do stuff with the post content. the_title(); the_permalink(); // Etc. endwhile; else: // Insert any content or load a template for no posts found. endif; wp_reset_query(); ?>
Questo in quanto la funzione query_posts cambia il valore iniziale della query.