我用這個片段來顯示故事的章節。但不知道為什么,它是有限的,只顯示10個項目。我無法解決這個問題。請你幫助我,伙計。global $post; $args = array( 'post_type' => 'story', 'post_status' => 'publish', 'order' => 'ASC', 'post_parent' => $post->ID ); $story = new WP_Query( $args ); if( $story->have_posts() ) : ?> <div class="story__main"> <h2 class="story__title-chapter">Danh sách các ch??ng</h2> <ul class="story__chapter"> <?php while( $story->have_posts() ) : $story->the_post();?> <li> <a href=<?php echo the_permalink();?>><?php echo get_the_title();?></a> </li> <?php endwhile;?> </ul> </div> <?php endif;
1 回答

森欄
TA貢獻1810條經驗 獲得超5個贊
嘗試設置該posts_per_page值。
$args = array(
'post_type' => 'story',
'post_status' => 'publish',
'order' => 'ASC',
'post_parent' => $post->ID,
'posts_per_page' => -1
);
重要提示:這可能會導致非常大的查詢,從而導致站點癱瘓。僅當您確定您的數據庫可以處理它時才執行此操作。不在公共主題或插件中。
參考
https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
- 1 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消