このスニペットでは、Professional WordPress Design and Development、2nd Editionの作成者がPHP変数($ wp_query)をNULLに設定して、完全にフラッシュします。
割り当てる前にこれを行う必要があるのはなぜですか?
<?php
$temp = $wp_query;
$wp_query= null;/***here***/
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$wp_query = new WP_Query( 'posts_per_page=5&paged='.$paged );/***here***/
while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<h2>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link( '« Previous' ); ?></div>
<div class="alignright"><?php next_posts_link( 'More »' ); ?></div>
</div>
<?php
$wp_query = null;/***here***/
$wp_query = $temp;/***here***/
?>