Redirecting users to a category page instead of a search results page
Hi,
I noticed visitors tend to use the search bar to reach a category much more often than they use the navigation menu, leaving the search field empty, choosing a category and then clicking Search, and I was wondering if there would be a way to redirect them to the actual category instead of displaying a results page...
The idea would be to redirect them whenever the search field is empty and a category is selected. I started working on it but I am stuck when it comes to redirection. In file search.php, here is what I did around line 30:
Code:
<?php
$catid = get_query_var('scat');
if ( $searchTxt = '*' && ! empty( $catid ) ) {
CODE FOR REDIRECTION
} else {
?>
<h1 class="single dotted"><?php printf( __( 'Search for \'%1$s\' returned %2$s results', APP_TD ), $searchTxt, $wp_query->found_posts );}?></h1>
Any idea what code I could use to redirect users based on the catid?
Alternatively, would it be possible to redirect them using a 302 or 307 redirect without affecting
SEO? I already have a plugin installed that can handle this.
Thanks for your input!