When I do a simple search(just ?s in the query) it shows the result in the search.php template. but when I try to filter the result by custom taxonomies I created(for example ?s=text&brand=text) it shows the result over the taxonomy archive template I created and not over search.php.

Is there any way to show every search query result over the search template page?

EDIT: after investigating it a little bit further i think i know whats the problem. i think woocommerce takes control over the rewrite rules and give priority to their custom taxonomies. any idea how to fix this? enter image description here


solved it with this code

function prefix_url_rewrite_templates() {
    if ( get_query_var( 's' ) ) {
        add_filter( 'template_include', function() {
            return get_template_directory() . '/search.php';
add_action( 'template_redirect', 'prefix_url_rewrite_templates' );

if there is a better way please notify me :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.