This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Ahax Pro search

#23620
Ernest MarcinkoErnest Marcinko
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;
}