[wp-hackers] Changing the number of search results

Ryan Boren ryan at boren.nu
Sun Sep 26 05:51:35 UTC 2004


> Quoting Matt Read <lists at mattread.com>:
>
>> if ($s) $posts_per_page = 25;
>
> The old query variables are rather obsolete. With the next officially
> stable
> build (or with the current CVS) you'll be able to do this:
>
> if (is_search()) $wp_query->query_vars['posts_per_page'] = 25;
>
> ... which negates the need for any global pollution.

You can't reliably reference either $s or is_search() before the include
of wp-blog-header.  $s will only be set if register_globals is enabled. 
is_search() relys upon the query processing done in wp-blog-header.  This
is why a plugin is necessary.

Ryan



More information about the hackers mailing list