06/06/2016 at 10:47 am
#378556
Keymaster
@ Matthew
This can be done, but requires a little code snippet to add this functionality. Here’s how:
Install the Code Snippets plugin.
Add a new snippet with the following code:
add_action( 'wp', 'cn_search_category_reset' );
function cn_search_category_reset() {
global $wp_rewrite, $post;
$keywords = get_query_var( 'cn-s' );
$categoryIDs = get_query_var( 'cn-cat' );
$categorySlug = get_query_var( 'cn-cat-slug' );
if ( ! empty( $keywords ) && ( ! empty( $categoryIDs ) || ! empty( $categorySlug ) ) ) {
cnSEO::doFilterPermalink( FALSE );
// Get the directory home page ID.
$homeID = cnSettingsAPI::get( 'connections', 'connections_home_page', 'page_id' );
$permalink = $wp_rewrite->using_permalinks() ? trailingslashit( get_permalink( $homeID ) ) : get_permalink( $homeID );
wp_redirect( add_query_arg( array( 'cn-s' => $keywords, 'cn-cat' => FALSE, 'cn-cat-slug' => FALSE ), $permalink ) );
exit;
} elseif ( ! empty( $categoryIDs ) && ! empty( $categorySlug ) ) {
cnSEO::doFilterPermalink( FALSE );
// Get the directory home page ID.
$homeID = cnSettingsAPI::get( 'connections', 'connections_home_page', 'page_id' );
$permalink = $wp_rewrite->using_permalinks() ? trailingslashit( get_permalink( $homeID ) ) : get_permalink( $homeID );
wp_redirect( add_query_arg( array( 'cn-cat' => $categoryIDs, 'cn-cat-slug' => FALSE ), $permalink ) );
exit;
}
}
Save and activate the snippet.
Now when a user does a search, the category selection will be reset.
Hope that helps! Let me know.
