[wp-hackers] Help with controlling search result (posts_per_page)

Sam Angove sam at rephrase.net
Tue Jun 13 21:43:27 GMT 2006

On 6/14/06, Paul Menard <codehooligans at codehooligans.com> wrote:
> So I've added a hidden form field of this name to my search form. Set
> the value to 5. When I search I still get the default of 10. I've
> tried to trace through the code and cannot determin what I'm doing
> wrong.

Happy Wednesday where I am!

IIRC posts_per_page is a private query var and can't be set that way
-- presumably this is because it'd otherwise be too easy to DOS a site
with requests for 9999 posts.

A simple plugin to set posts_per_page to 5 if (is_search()) doesn't
seem like a bad solution to me. That and re-calling get_posts() are
the only solutions that spring to mind.

More information about the wp-hackers mailing list