Codex

Riferimento funzioni/wp reset postdata

Contents

Descrizione

Dopo aver eseguito un ciclo tramite una query differente, questa funzione ripristina il $post globale all'articolo corrente della query principlae.

Utilizzo

<?php wp_reset_postdata(); ?>

Parametri

Questa funzione non accetta alcun parametro.

Valori di riotrno

Questa funzione non restituisce alcun valore.

Esempi

$query_originale = $wp_query;
$wp_query = null;
$wp_query = new WP_Query( $args );
if ( have_posts() ) :
	while ( have_posts() ) : the_post();
		the_title();
		the_excerpt();
	endwhile;
else:
	echo 'nessun articolo trovato';
endif;
$wp_query = null;
$wp_query = $query_originale;
wp_reset_postdata();

Note

  • Utilizza: $wp_query

Change Log

File sorgente

wp_reset_postdata() si trova in wp-includes/query.php.

Correlati

Query Tags: WP_Query (Classe), get_query_var(), query_posts(), have posts(), the_post(), rewind_posts(), wp_reset_postdata(), wp_reset_query()

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