• Resolved marcusds

    (@marcus1060)


    In a function in a theme’s functions.php I have

    $postslist = get_posts('posts_per_page=3');
    echo count($postslist);

    Why does it keep returning more than 3? How do I fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter marcusds

    (@marcus1060)

    OK, well after a long time searching I believe I’ve found the issue by looking in the source code.
    Should be numberposts not posts_per_page. The Docs list it incorrectly.

    Posting this here if anyone stumbles upon this with the same problem.

    It appears that this was corrected in WP 3.1, though plugin developers shouldn’t use it for a while, to preserve backwards compatibility.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_posts ignoring posts_per_page’ is closed to new replies.