Cannot Find Target Term when Apostrophe and 's added.

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Cannot Find Target Term when Apostrophe and 's added.

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 months, 1 week ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37153
    albert71
    albert71
    Participant

    Hi,

    1. I need to add another search instance at https://infinitusnow.site/our-parishes/ (the main search is available at the top of every page). This new instance must only search within the page ie the churches in the directory. When there are results, ASP should scroll to the first result and highlight the search term.
    => Essentially like using Cmd-F to search within a page.

    2. While using the current search instance at the top of the page, “HIlda” generates results but not “Hilda'” or “Hilda’s”. “Hilda’s” exists on the page. (see attached image).

    Thanks
    Albert

    Attachments:
    You must be logged in to view attached files.
    #37163
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    1. I’m afraid that is not possible. This kind of front-end search (like the browser CTRL + F) is best to have custom coded for the specific page. It is usually not too complicated, but best to ask a developer about specific details.
    This plugin is to search back-end objects (via database) and return them as singular results – such as individual posts/pages etc.. – so it would only return the single page as the result. The CTRL+F is a pure front-end javascript search.

    2. The apostrophes are generally not touched within the phrase the user enters, so it can match items with the apostrophe in it. If the word hilda’s is not present in the text, then it will not match. The easiest way to deal with them is via using a custom code to get rid off the unwanted characters, and replace them preferably with a space character.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter('asp_search_phrase_before_cleaning', 'asp_replace_characters', 10, 1);
    add_filter('asp_query_args', 'asp_replace_characters', 10, 1);
    
    function asp_replace_characters( $s ) {
      $characters = "'’‘’"; // Type characters one after another
      $replace_with = ' ';     // Replace them with this (space by default)
    
      if ( is_array($s) ) {
        if ( isset($s['s']) && !$s['_ajax_search'] ) 
          $s['s'] = str_replace(str_split($characters), $replace_with, $s['s']);      
      } else {
        $s = str_replace(str_split($characters), $replace_with, $s);
      }
    
      return $s; 
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #37168
    albert71
    albert71
    Participant
    You cannot access this content.
    #37176
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Very unleky, this has to be implemented exactly for the specific page output unfortuantely. It is possible to custom code it, and it is rather simple in my opinion (although I have only seen ready-made examples, those were not too complex), but it also has to work on at least 90% of the cases for customer sites, and that makes it currently impossible.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #37182
    albert71
    albert71
    Participant
    You cannot access this content.
    #37184
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    2. The Lite and the Pro version are two different plugins, and the Pro version uses a different shortcode. If you replace it with that, it will work again 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.