2015-06-26 155 views
0

我一直在遇到問題。 我正在編輯自定義WordPress主題。我想對常見問題頁面(使用自定義帖子類型創建)進行一些調整。Wordpress - 增加特定類別內顯示的帖子數量

現在,每個問題的主題(=也是類別)只顯示5個答案(這些是帖子)。 我想知道,我可以如何增加這個數字,而不是5,顯示10或者更確切地說,顯示每個主題的所有答案。

這是代碼: 歸檔faq.php

    <?php $terms = get_terms('faq_category'); ?> 
       <?php foreach($terms as $term): 
        $args = array (
         'post_type'    => 'faq', 
         'tax_query' => array(
          array(
           'taxonomy' => 'faq_category', 
           'field' => 'id', 
           'terms' => $term->term_id, 
          ), 
         ), 
        ); 

        $query = new WP_Query($args); ?> 

        <h1><?php echo $term->name; ?></h1> 

        <?php while ($query->have_posts()) : $query->the_post(); ?> 

         <div class="toggle-holder"> 
          <h5 class="toggle"><span><?php the_title(); ?></span></h5> 
          <div class="toggle-box"> 
           <div> 
            <?php the_content(); ?> 
           </div> 
          </div> 
         </div> 

        <?php endwhile; ?> 
       <?php endforeach; ?> 
       <?php wp_reset_postdata(); ?> 

一個重要組成部分是:

       <div class="toggle-box"> 
           <div> 
            <?php the_content(); ?> 
           </div> 
          </div> 

當the_content(),則表明在某一類別的職位。 但無處可尋,爲什麼,該頁面只顯示最多5個帖子(答案),而不再是?

事情我已經嘗試:

$query = new WP_Query($args); 
        $query_posts('post_per_page=3'); ?> 

另外: 把'showposts' => 8'terms' => $term->term_id,

而且我也試過:

   $query = new WP_Query($args); ?> 

         <?PHP 
               query_posts(array(
'workcap' => $all_post_terms, 
'showposts' => 8, 
'caller_get_posts' => 1, 
'post__not_in' => $do_not_duplicate)); ?> 

- >>總結: 爲什麼會出現頁面最多隻能顯示5個帖子? 如何更改此屬性?

PS。如果您想查看頁面:http://goo.gl/UnWRTz

回答

0

參數是posts_per_page而不是post_per_page。它是一個錯字?事實上https://codex.wordpress.org/Class_Reference/WP_Query

+0

一個錯字:

試試這個:

$args = array ( 'post_type' => 'faq', 'posts_per_page' => -1, //for now try without this taxonomy, if it works try with it. /*'tax_query' => array( array( 'taxonomy' => 'faq_category', 'field' => 'id', 'terms' => $term->term_id, ), ),*/ ); 

順便說一句,你可以在這裏找到更多信息。問題已解決。 非常感謝。 – user3170966

相關問題