Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › 500 error › Reply To: 500 error
November 11, 2022 at 11:19 am
#39958
Keymaster
The issue was not related to the plugin, you had a custom code in your functions.php file which was incorrect and caused the error. I made a correction to it, now it is going to be fine. For reference, this is the correct code:
// Replace search phrases
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 ) {
$before_strings = array(
"landc" => "land c", //land cruiser
"brakes" => "brake",
"rangero" => "range ro", //range rover
"landr" => "land r", //land rover
"towb" => "tow b", //towbar
"bellh" => "bell h", //bellhousing
"extractor" => "header",
"pickup" => "ute",
"hood" => "bonnet",
"mfg12" => "mfk12",
"brake disc" => "brake rotor",
"adapte" => "adapto",
"centref" => "centerf",
"hydrob" => "hydro b"
);
foreach($before_strings as $key => $value){
if ( is_array($s) ) {
$s['s'] = str_replace($key, $value, $s['s']);
} else {
$s = str_replace($key, $value, $s);
}
};
return $s;
}