[wp-hackers] Filter search query before execution

Milan Dinić liste at srpski.biz
Mon Oct 18 20:53:12 UTC 2010


Thanks, this solves issue with menus.


2010/10/18 scribu <mail at scribu.net>

> On Mon, Oct 18, 2010 at 8:53 PM, Milan Dinić <liste at srpski.biz> wrote:
>
> > 2) if custom menus are used, they are completely broken (menus contain
> > search results)
> >
>
> Instead of:
>
> function md_lattocyr_search_filter($search) {
>  global $wp_query
>
>  // rest of code here
> }
>
> add_filter('posts_search', 'md_lattocyr_search_filter');
>
> write:
>
> function md_lattocyr_search_filter($search, $wp_query) {
>  if ( $GLOBALS['wp_query'] !== $wp_query )
>    return $search;
>
>  // rest of code here
> }
>
> add_filter('posts_search', 'md_lattocyr_search_filter', 10, 2);
>  _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list