次のスクリプトを使用して、WordPress ページに 3 つのエントリを出力しています。
ただし、何らかの理由で、そのリストの最初のエントリのみを出力します。配列内で数値を移動しましたが、まだ 1 しか出力されません<div>
。
IDが1、4、31の投稿が確実にあるにもかかわらず。
これを修正する方法はありますか?
<?php $thePostIdArray = array("1","4","31"); ?>
<?php $limit = 3; ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); $counter++; ?>
<?php if ( $counter < $limit + 1 ): ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?php $post_id = $thePostIdArray[$counter-1]; ?>
<?php $queried_post = get_post($post_id); ?>
<h2><?php echo $queried_post->post_title; ?></h2>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
ご指摘ありがとうございます。