Codex tools: Log in
Languages: English • Italiano • (Add your language)
Contents |
Dopo aver eseguito un ciclo tramite una query differente, questa funzione ripristina il $post globale all'articolo corrente della query principlae.
<?php wp_reset_postdata(); ?>
Questa funzione non accetta alcun parametro.
Questa funzione non restituisce alcun valore.
$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();
wp_reset_postdata() si trova in wp-includes/query.php.
Query Tags: WP_Query (Classe), get_query_var(), query_posts(), have posts(), the_post(), rewind_posts(), wp_reset_postdata(), wp_reset_query()