Site logo

Archived topic

Search function error

3 replies · Started by An Nguyen on October 24, 2019

Viewing posts 1–4 of 4

Hi,

I tried to limit search only title because a visitor clicks on search icon without typing any thing, then my website list all category id page, ....

I searched I saw an option from David :https://generatepress.com/forums/topic/limit-search-to-page-titles/

I used this code (https://developer.wordpress.org/reference/hooks/posts_search/#user-contributed-notes) and it leads to error below:

Error:

Warning: Parameter 2 to __search_by_title_only() expected to be a reference, value given in /home/...../public_html/wp-includes/class-wp-hook.php on line 286

Warning: Parameter 2 to __search_by_title_only() expected to be a reference, value given in /home/...../public_html/wp-includes/class-wp-hook.php on line 286

How can I deal with this case?

Hi there,

What if you change the function name to this?: __search_by_title_only( $search, $wp_query ) {

Perfect!

Thanks Tom.

You're welcome :)

This archived topic is closed to new replies.