Reply To: Change results base url

#978

Ernest Marcinko
Keymaster

Hi!

Thank you! I would rather recommend using PHP to achieve such thing insted of javascript. The good thing with v2.0 is that I have implemented a bunch of filters and actions, that we can use to make our lives easier 🙂

However there is no filter for changing the url, there is still a way around it. The filter called “asp_results” passes all the results as an array of objects to a desired function. This means, that we can scrape the url out of it and change it as we like:

  add_filter('asp_results', 'my_changeBaseUrl',10,1);
  
  function my_changeBaseUrl($results) {
      foreach ($results as $k=>$result) {
        $results[$k]->link = str_replace("replace this", "with this", $result->link);
      }
      return $results;
  }

You can put this code to you templates functions.php file, or into the bottom of the plugins/ajax-search-pro/search.php file. If you replace the “replace this” and the “whith this” string in this code with the desired string, it should work 🙂

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)