Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ignoring special characters › Reply To: Ignoring special characters
Hi Majid,
So, my suggestion is using a custom code with the index table engine. The custom code will try to replace these characters with the single unicode versions on both the server and client side.
Please follow the instructions below:
1. Please add 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('asp_indexing_string_pre_process', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
add_filter('asp_search_phrase_before_cleaning', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
add_filter('asp_query_args', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
function custom_chars_asp_indexing_string_pre_process($s) {
$original = array(
'ī', 'ʻ', 'ā', 'Ṭ', 'ṣ', 'ū'
);
$replace = array(
'i', '', 'a', 't', 's', 'u'
);
// Replace them
if ( is_array($s) ) {
if ( isset($s['s']) && !$s['_ajax_search'] )
$s['s'] = str_replace($original, $replace, $s['s']);
} else {
$s = str_replace($original, $replace, $s);
}
return $s;
}
2. Make sure to configure the index table engine. Follow the tutorial.
3. Once ready and the indexing is finished. Make sure the index table is enabled
If all goes right, entering the words should yield results. The code will only replace the given characters, only the lowercase versions. For this to work with the upper case, it needs to be added as well.
-
This reply was modified 5 years, 11 months ago by
Ernest Marcinko. Reason: Fixed code