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

#28608
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Depending on the situation, I recommend two possible solutions:

1. You can set the search to redirect to a custom URL, where you can add a static parameter, like ?s={phrase}&cat=1

2. To use the redirection to custom URL, and add the parameters conditionally via custom code based on this example. In your case, something like this:

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

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

  return $url;
}