• Titles on my site are done using proper apostrophes. Unfortunatly this results in some people not getting a result when they search as they use the foot marker “‘” instead of a proper apostrophe “’”.

    Is there a way to have the plugin return a result if either are used in the search

    Ender’s Game (with a proper apostrophe) gets result
    Ender’s Game (the foot marker may people use when typing) does not get result

    https://wordpress.org/plugins/ultimate-wp-query-search-filter/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TC.K

    (@wp_dummy)

    You are refer to the keyword search right?
    So, you can do this:

    add_filter('uwpqsf_query_args','replacing_apostrophe','',3);
    function replacing_apostrophe( $args, $id,$getdata){
       $text = $args['s'];
       $args['s'] = str_replace("'", '’', $text);
       return $args;
    }

    Above is for ajax template, if you are using default template you might want to change uwpqsf_query_args to uwpqsf_deftemp_query.

    Thread Starter Ian Sterne

    (@ian-sterne)

    OK I added your code

    add_filter('uwpqsf_deftemp_query','replacing_apostrophe','',3);
    function replacing_apostrophe( $args, $id,$getdata){
       $text = $args['s'];
       $args['s'] = str_replace("'", '’', $text);
       return $args;
    }

    and it is still not working for me when I search for Ender’s I get no posts found. the apostrophe is not replaced properly and after the search the keyword field shows Ender\’s

    Plugin Author TC.K

    (@wp_dummy)

    Well, that’s the problem where wp will escape the “‘”.
    You can try with html number of apostrophe.
    Refer to here.

    Thread Starter Ian Sterne

    (@ian-sterne)

    OK this is still not working. I am using:

    The code that was in the paste bin link supplied.

    It is not replacing the “‘” in the search that I can see, it is replacing the text in the search box with “\'”

    would love to sort this out.

    Plugin Author TC.K

    (@wp_dummy)

    What is your database encoding.
    You can try replace with ’
    Refer here

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Apostrophe in Search’ is closed to new replies.