Forums › Forums › Search & Filter Pro › /category page url redirect to search and filter page
- This topic has 3 replies, 2 voices, and was last updated 6 years, 7 months ago by
Trevor.
-
Anonymous(Private) November 30, 2018 at 10:49 pm #195080
Hi,
We need to redirect category urls to our search and filter results page. Is there a setting for this? I tried to use a url redirect:/category/(.*) to /ministries-small-groups-directory/?_sft_category=$1
I added this redirection but it adds a / to the end which pages the search not work for example:
https://devchurch.wpengine.com/category/sports-recreation
redirects to:
https://devchurch.wpengine.com/ministries-small-groups-directory/?_sft_category=sports-recreation/Is there any setting to be able to do this or a way to remove the / at the end so that the filter page works?
Thanks so much for your help!
AmyTrevor(Private) December 3, 2018 at 5:00 pm #195162ah, I can see it is in a private area. Here it is:
Well essentially the question is “how do I redirect woocommerce archives.. to a custom URL”
Well if you need to do it via htaccess (which might get tricky) this should help:
https://stackoverflow.com/questions/4799910/htaccess-rewrite-subdirectory-name-to-querystring-param
But I think the easiest & most reliable way would be to use php redirect in functions.php, and detect the current category (it won’t be as fast though). Something like this (untested) should work for redirecting all product category archives to a URL like you describe:
function my_page_template_redirect() { if( is_tax( 'product_cat' ) ){ global $wp_query; $product_slug = $wp_query->get_queried_object()->slug; $redirect_url = add_query_arg(array( '_sft_product_cat' => $product_slug ), home_url('/myshoppage/') ); wp_redirect( $redirect_url ); die; } } add_action( 'template_redirect', 'my_page_template_redirect' );
Hope that helps.
-
AuthorPosts