<?php // 引数の例 $args = array( 'posts_per_page' => 3 ); // クエリを実行する $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : ?> <!-- ループの始まり --> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php the_title(); ?> <?php the_excerpt(); ?> <?php endwhile; ?><!-- ループの終わり --> <!-- ページ送り関数をここに入れる --> <?php wp_reset_postdata(); ?> <?php else: ?><!-- 条件に合う投稿が見つからない場合 --> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?>
WP_Query()でループする際に、wp reset postdata()は必須なのでしょうか。例えば、このループの例では、wp reset postdata()を記述しないと不具合が起きるのでしょうか。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。