Reply To: How create specific results url ?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How create specific results url ? Reply To: How create specific results url ?

#9697
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

Thank you for your kind words!

Well, if I understand correctly you want to assign a custom URL for some of the results. You will need a bit of a custom code for that.

Solution 1
I usually suggest using a custom field on the post editor to store a custom URL if it’s different for each result. Then you can use that custom field to replace the results. Knowledge base: Changing results url to a custom field

Solution 2
If the URL is static for each result, or if you want to manipulate it, then this code would be the best to start with in your case. Use this in the functions.php file in your active theme directory:


add_filter( 'asp_results', 'asp_change_url_on_terms', 1, 1 );
  
function asp_change_url_on_terms( $results ) {
  $options = $_POST['options'];
  
  if ( isset($options['termset']['periodes']) && $options['termset']['periodes'] == 68 ) {
    foreach ($results as $k=>&$r) {  
      $r->link  = "your custom URL here";
    }
  }

  return $results;
}

I’ve customized this code so, In this case the foreach statement is only executed when the “Juillet/Aout” taxonomy term is selected. Change the $r->link variable to the URL you wanted.

Best,
Ernest Marcinko

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