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

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24555
    chrisreeveschrisreeves
    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 MarcinkoErnest 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.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.