08/04/2014 at 8:21 am
#299488
Keymaster
@ Craig
I developed a snippet for another user that may help with this issue a little.
Install the Code Snippets plugin and add the following code as a new snippet.
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;
}
}
I will not do much about the pagination links but it should help clear up the issue of clicking the category link in the sidebar and then changing the category in the drop down… in case you would like to use that again.
