过去三天我一直在研究这个。我要限制get_posts().
我有这段代码:
// all filters should be applied here
$args = array(
    \'nopaging\'                  => true,
    \'post_type\'                 => get_option(\'ip_slug\'),
    \'posts_per_page\'            => $ip_ipp,
    \'limit\'                     => 100,
    \'orderby\'                   => $ip_order,
    \'order\'                     => $ip_order_asc_desc,
    \'author\'                    => $author,
    \'suppress_filters\'          => false,
    \'meta_key\' => $ip_meta,
    \'meta_query\' => array(
        array(
            \'key\' => $ip_key,
        )
    ),
    \'cache_results\' => false,
    \'update_post_term_cache\' => false,
    \'update_post_meta_cache\' => false,
    \'no_found_rows\' => true,
);
$posts = get_posts($args);
//
 The
limit 参数不起作用。
UPDATE #1: 我想用,比如说,5 每页发表文章,并在同一页上使用多个查询get_posts() (不是query_posts, 不WP_Query) 我想将数据库查询限制为100. 我不能用paged 参数,因为有多个动态创建的循环。
 
                    最合适的回答,由SO网友:Ciprian 整理而成
                    我已经解决了这个问题,我使用了posts_per_page 值为的参数100 并已使用jPages 用于jQuery分页。
Explanation: 在我的情况下,由于我需要获得有限的职位,210 - 我想同时使用分页和查询限制。因为这似乎不可能使用get_posts(), 我用了posts_per_page 值为的参数210 并实现了jPages分页。虽然不是最优雅的解决方案,但它确实起到了作用。