我已經(jīng)設(shè)置了一個自定義字段來提取指定的類別ID,以便在頁面?zhèn)葯谏鲜褂肳P_Query來顯示。它會將帖子拉入正確的類別,但會跳過最新的帖子。以下是代碼片段:<?php $catID = get_field ( 'category_id_posts' ); $catquery = new WP_Query( 'cat='. $catID .'&posts_per_page=5' ); ?> <?php if($catquery->have_posts()) : $catquery->the_post(); ?> <div id="recent-posts-2"> <h3 class="widget-title">Recent Posts</h3> <ul class="nav flex-column"> <?php while($catquery->have_posts()) : $catquery->the_post(); ?> <li class="nav-item"> <a class="nav-link" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> </li> <?php endwhile; ?> </ul> </div> <?php endif; wp_reset_postdata(); ?>即使我簡化了WP_Query并像這樣刪除變量:$catquery = new WP_Query( 'cat=7&posts_per_page=5' );它仍然會跳過該類別中的最新帖子。任何見解將不勝感激,謝謝!
Wordpress:類別Feed中缺少的最新帖子
函數(shù)式編程
2022-08-05 16:08:48