• Resolved bonz

    (@bonz)


    Hello,
    I am using this great plugin for some time, but now I have a problem.
    I have a plugin that does not recognize the apostrophe, but it is very useful, it is a shopping cart
    I sell backing track and many titles have the apostrophe, to make it recognize I use the encoding ' in cms editor and the titles have the apostrophe seen on the site
    but when I do a search the result is “no results!”
    what can I do?
    thank you very much for the answer

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    Because the characters are stored encoded, the query probably returns a non-match for the unencoded character. The best possible solution in my opinion is to use a small custom code snippet that simply removes the apostrophes before it is passed to the search query, as if it was not even typed in.

    To do that, just ddd this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter('asl_search_phrase_before_cleaning', 'asl_replace_characters', 10, 1);
    function asl_replace_characters( $s ) {
      $characters = "’'"; // Type characters one after another
      $replace_with = '';     // Replace them with this (space by default)
      
      $s = str_replace(str_split($characters), $replace_with, $s);
    
      return $s; 
    }

    This will remove the unwanted apostrophe from the search phrase whenever it’s entered.

    Thread Starter bonz

    (@bonz)

    hi,
    thanks, I’ll try this code
    thanks again

    Thread Starter bonz

    (@bonz)

    Hello,
    I tried the code you sent me, and I have to say it works great
    thanks endless
    bonz

    Plugin Author wpdreams

    (@wpdreams)

    Great, thank you for letting me know ??

    Feel free to rate the plugin if you want to, it’s greatly appreciated. I will mark this thread as resolved now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘search problem’ is closed to new replies.