False results with get_posts and posts_per_page = 0 (2 posts)

  1. devonmather
    Posted 2 years ago #

    Working on a real estate site, users can shortlist properties and store them in a cookie, for later browsing. This all works fine, but if they have no shortlisted properties then the 5 most recent properties get returned.

    $args = array( 'posts_per_page' => $shortCount,
    'post_type' => 'property',
    'include' => $shortlistedObj->properties
    $posts = get_posts($args);

    If I print_r($args) before get_posts() I get the following,

    [posts_per_page] => 0
    [post_type] => property
    [include] => Array ()

    Is this a bug or am I using posts_per_page incorrectly?


  2. vtxyzzy
    Posted 2 years ago #

    I think you may need to check $shortCount and if it is zero, set it to 5.

Topic Closed

This topic has been closed to new replies.

About this Topic