Search instance based restrictions with asp_results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search instance based restrictions with asp_results

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24555
    chrisreeves
    chrisreeves
    Participant

    Hi,
    We are using the following code change the links of the search results.

    add_filter( ‘asp_results’, ‘asp_number_results’, 1, 1 );
    function asp_number_results( $results ) {
    foreach ($results as $k=>$v) {
    $results[$k]->link = $results[$k]->link . “?support&”.$results[$k]->ID;
    }
    return $results;
    }

    We have multiple instances and only need this to work on one search instance. Is it possible to restrict this function to run on a single instance? Currently this is running for all instances.

    #24556
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Yes, you can. There are three additional arguments to that hook, one of them is the search ID. Use this variation instead:

    add_filter( 'asp_results', 'asp_number_results', 10, 4 );
    function asp_number_results( $results, $search_id, $is_ajax, $search_args ) {
      if ( $search_id == 1 ) {
        foreach ($results as $k=>$v) {
          $results[$k]->link = $results[$k]->link . "?support&".$results[$k]->ID;
        }
      }
      return $results;
    }

    Just change the first line to the search ID you want to apply this on, and that is it.

    Best,
    Ernest Marcinko

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


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.