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

Reply To: How to show search results for a category in a specific template

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How to show search results for a category in a specific template Reply To: How to show search results for a category in a specific template

#28616
Ernest MarcinkoErnest Marcinko
Keymaster

Well, the problem is, that the hook does not pass the search ID. However making a change to one of the core files will fix that as well:
1. Open up the wp-content/plugins/ajax-search-pro/includes/views/asp.shortcode.script.php file on your server
2. Replace it’s contents with this
3. Save

Now, the filter accepts a second parameter, which is the search ID:

// Use this to change the "redirect to url" parameter
add_filter( 'asp_redirect_url', 'asp_add_params_to_url', 2, 10 );
// Use this to change the "show more results url" parameter
add_filter( 'asp_show_more_url', 'asp_add_params_to_url', 2, 10 );

function asp_add_params_to_url( $url, $id ) {
  // Array of param names and values
  $values = array(
    "cat" => "1"
  );
  // Merge them together
  foreach ( $values as $k => $v )
    $url .= "&".$k."=".$v;

  return $url;
}

I will include this change in the upcoming release, so you don’t have to worry about the additional parameter.