Wordpress-增加在特定类别中显示的帖子数量


Wordpress - Increase amount of posts to be shown within specific category

我遇到了一个问题。我正在编辑一个自定义wordpress主题。我想对常见问题页面(使用自定义帖子类型创建)进行一些调整。

现在,每个问题(=也是类别)只显示5个答案(这些是帖子)。我想知道,我怎么能增加这个数字,所以显示10,而不是5,或者更确切地说,显示每个主题的所有答案。

这是代码:archive-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>

其中,_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

参数是posts_per_page而不是post_per_page。是打字错误吗?

试试这个:

$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,
        ),
    ),*/
);

顺便说一句,你可以在这里找到更多信息:https://codex.wordpress.org/Class_Reference/WP_Query