如何根据自定义元限制返回的帖子?

时间:2014-08-10 00:02:46

标签: php wordpress

这会检索帖子,但不会限制返回的帖子数量。我如何限制它?

// Query Args
$args = array(
    'post_status' => 'published',
    'posts_per_page' => '5',
    'category_name' => 'payment',
    'meta_query' => array(
                    'key' => 'payment_club',
                    'value' => $current_user->user_login,
            )
);

1 个答案:

答案 0 :(得分:1)

试试这个:

 $args = array(
        'post_status' => 'published',
        'posts_per_page' => 5,
        'category_name' => 'payment',
        'meta_query' => array( array(
                             'key' => 'payment_club',
                             'value' => $current_user->user_login
                           )
                       )
    );

我认为posts_per_page必须是整数