Reply To: Ajax Search pro – incorrect woocommerce product links in search result

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Ajax Search pro – incorrect woocommerce product links in search result Reply To: Ajax Search pro – incorrect woocommerce product links in search result

#3731

Ernest Marcinko
Keymaster

Hi!

I did a bit of a research, and this might be a wordpress related bug. The search uses the general get_permalink() function to return the correct url, but for some reason it fails. Before touching anything you should try these steps:

  • Save the permalink settings again on the wordpress settings panel
  • Deactivate/activate WooCommerce and Ajax Search Pro

This should refresh the permalink cache, and it might help.

If not, then another solution is to connect a function to the results link filter and add the “produkt” part manually:

If the upper mentioned solutions are not working, then add the following code to your themes functions.php file. It will try to fix the url.

add_filter( "asp_results", "asp_fix_woocommerce_link", 1, 1 );

function asp_fix_woocommerce_link( $results ) {
  $home_url = home_url();
  
  if (strpos($home_url, "hundbutik") === false) {
    foreach ($results as $k=>$v) {   
      $results[$k]->link = str_replace("hundbutik/", "hundbutik/produkt/", $results[$k]->link);
    }
  }
 
  return $results;
}
Best,
Ernest Marcinko

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