I want to make a search URL look like this:
example.com/search/search+query?post_type=product.
I have tried many methods including this:
wp_redirect( home_url( "/search/?s=" ) . urlencode( get_query_var( 's' ) . "&post_type=" . urlencode( get_query_var( 'post_type' ) ) );
and this:
wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ). "?post_type=". urlencode( get_query_var( 'post_type' ) ) ) );
but the result I am getting:
example.com/search/search+query%3Fpost_type%3Dproduct
What should I do?