[Resolved] Search function error

Home Forums Support [Resolved] Search function error

Home Forums Support Search function error

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1043911
    An Nguyen

    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?

    #1044483
    Tom
    Lead Developer
    Lead Developer

    Hi there,

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

    #1044494
    An Nguyen

    Perfect!

    Thanks Tom.

    #1044686
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.