Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ahax Pro search › Reply To: Ahax Pro search
July 6, 2019 at 4:04 pm
#23620
Keymaster
Thank you!
I have managed to make the change, please check it.
For future reference, this is the code I added:
// AJAX SEARCH PRO
add_filter( 'asp_query_args', 'asp_replace_search_keywords', 10, 2 );
function asp_replace_search_keywords( $args, $id ) {
/**
* Add as many words as you want. On the left side place the
* word or words separated by comma to replace.
* To the right side, place the single word to replace it with.
*/
$replace = array(
"ps4" => "playstation 4",
"ps3" => "playstation 3",
"ps2" => "playstation 2",
"ps1, psone, ps one, ps, psx" => "playstation 1",
"snes" => "super nintendo",
"n64" => "nintendo 64",
"wiiu" => "nintendo wii u",
"gc" => "nintendo gamecube",
"gameboy, gb" => "game boy",
"gameboy, gb, gbc" => "game boy color",
"gameboy, gba" => "game boy advance",
"xb1," => "xbox one"
);
// ----------------------------------------
// Do not change anything below this line
// ----------------------------------------
foreach ( $replace as $k => $w ) {
$kr = explode(',', $k);
foreach ($kr as $krk => &$krv) {
$krv = trim($krv);
if ( $krv == '' ) {
unset($kr[$krk]);
} else {
$krv = '/\b' . $krv . '\b/u';
}
}
if ( count($krv) > 0 ) {
$args['s'] = preg_replace($kr, $w, strtolower($args['s']));
}
}
return $args;
}