posts_per_page不超过375限制

时间:2014-04-02 10:01:26

标签: php wordpress wp-query

如果帖子限制设置超出了它的范围,我的查询似乎不想运行...即如果我有370行信息并且我将posts_per_page设置为超出该范围的任何内容,它将不会运行查询?!

wp_reset_query();

    $args = array(
        'post_type' => 'courses',
        'posts_per_page' => 370,
        'post_status' => 'publish',
    );

    $loop = new WP_Query( $args );

我已尝试使用1000,-1,所有排序,但只有在输入预期的确切行数时才会起作用,否则脚本无法在WP_Query阶段运行,因此也没有任何错误。< / p>

编辑:实际限制似乎是375,之后,虽然有386个实际行符合标准,但没有执行任何操作。

有什么想法吗?!!

3 个答案:

答案 0 :(得分:0)

<?php 
   $args = array(
        'post_type' => 'courses',
        'post_status' => 'publish',
        'order' => 'DESC',
        'orderby' => 'date',
        'posts_per_page' => 370,
    );
    query_posts($args);

    while ( have_posts() ) : the_post(); ?>

    <?php echo the_content(); ?>


<?php 
    endwhile; 
    wp_reset_query();
?>

答案 1 :(得分:0)

这必须工作

<?php 

    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'courses',
        'post_status' => 'publish',
    );

    $the_query = new WP_Query( $args );

    if($the_query->have_posts()) : 
        while($the_query->have_posts()) : 
         $the_query->the_post(); ?>

    YOUR HTML CODE
<?php endwhile;  endif; ?>

答案 2 :(得分:0)

除了我的CTP限制为411之外,我遇到了同样的问题。更多的行和查询都没有用。遇到了一些类似的帖子和一个解决方案是增加服务器资源,但后来我寻找了如何提高wp_query性能。试试这个:

 $args = array(
    'post_type' => 'courses',
    'posts_per_page' => -1,
    'post_status' => 'publish', 
'update_post_term_cache' => false, // don't retrieve post terms
    'update_post_meta_cache' => false, // don't retrieve post meta
);

它对我有用,在显示CTP索引列表页面时似乎是一个不错的选择。在这里讨论:

https://drujoopress.wordpress.com/2013/06/27/how-to-optimize-wordpress-query-to-get-results-faster/#more-184

http://codex.wordpress.org/Class_Reference/WP_Query#Caching_Parameters