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
July 22, 2020 at 4:06 pm
#28616
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.