次のようなコードがあります。これは何らかの理由で無限ループを引き起こします。何が起こっているのか説明できますか?
ありがとうございます。
<?php
$flagged_stores = new WP_Query( array ( 'post_type' => 'store', 'orderby' => 'post_id', 'meta_key' => 'flagged', 'limit' => 10 ) );
if($flagged_stores->have_posts()): ?>
<div class="table">
<table class="form-table">
<tr>
<th>Store</th>
<th>Flag Reason</th>
<th>Delete Flag</th>
</tr>
<?php while($flagged_stores->have_posts()): ?>
<td><?php echo the_title(); ?></td>
<td><?php// echo get_post_custom_values('flagged'); ?></td>
<td><?php// echo "Delete"; ?></td>
<?php endwhile;?>
</table>
<?php else: ?>
No flags found.
<?php endif; ?>
この答えを見てください。 タグでカスタム投稿タイプを取得します
私はあなたがwhile
ループの中で$flagged_stores->the_post()
を使うことを信じる。
これが無限ループの原因となっているのかどうかはわかりませんが、WP_Queryはオフになっています。
$flagged_stores = new WP_Query( array ( 'post_type' => 'store', 'orderby' => 'ID', 'meta_key' => 'flagged', 'posts_per_page' => 10 ) );
'orderby'
と'posts_per_page'
を更新しました。