So the documentation on the Codex is pretty clear that showposts is deprecated. But that same documentation mentions nothing of numberposts. Instead, posts_per_page is listed.

But if we turn to the Codex docs for get_posts we see no mention of posts_per_page, instead citing numberposts.

In post.php we see what's happening: numberposts is set up as a default (5), but then copied to posts_per_page (unless posts_per_page is set in the args).

So my question is really quite pedantic, but I'm looking to update Codex so I wanted to ask you guys - is there a reason why we wouldn't want to just encourage posts_per_page across the board, eventually deprecating numberposts? Or am I missing some critical insight here?

  • 1
    Since numberposts is deprecated, it's best a best practice to use posts_per_page from here out. – Brian Fegter Sep 19 '11 at 23:13
  • @Brian, can you point me to where you see that numberposts is officially deprecated? I couldn't find it anywhere in the source. – Tom Auger Sep 20 '11 at 12:42
  • Sorry, I was referring to showposts. codex.wordpress.org/Class_Reference/… I apologize. – Brian Fegter Sep 20 '11 at 14:11

In my opinion, deprecating numberposts would not make sense, as numberposts is used to query x amount of posts, whilst posts_per_page is used to denote how many posts per page are being shown during pagination. If you were to deprecate numberposts in favor of simply posts_per_page, then pagination would not exist.


"numberposts" => 50, "posts_per_page" => 10

a total of 50 posts to query, 10 posts per page, giving 5 pages of 10 posts each.

removal of numberposts:

"posts_per_page" => 50

a total of 50 posts to query, 50 posts per page (since it copies the value of numberposts to posts_per_page), giving 1 page of 50 posts and no pagination.

Let me know if I'm just reiterating what you're already aware of, and I'm just slightly confused by the question.

  • 3
    I agree that they sound like they should do different things, but if you study the code, they actually don't! I actually prefer "numberposts" in some cases, like where the notion of "pages" doesn't really come into play - like some output in a sidebar widget, for instance. – Tom Auger Apr 24 '12 at 18:01
  • 1
    I think numberposts is needed when you need to query all posts by passing -1 which you can't do with posts_per_page – iSaumya Aug 6 '19 at 7:42
  • 2
    @iSaumya not true - the docs for WP_Query pagination params explicitly say you can pass posts_per_page = -1 – acobster Aug 21 '20 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.