I want to searchable archives like following:
Default Search:
/search/{keyword} -> search.php -> get_template_part('archive-default-search');
Default Custom Archive:
/support -> archive-support.php
Mixed:
/support/search/{keyword} -> search.php -> get_template_part('archive-support-search');
I could not achieve this. How can I do it?
add_action( 'init', function() {
add_rewrite_rule( '/(.+)/search/(.+)/?$', 'index.php?post_type=$matches[1]&s=$matches[2]', 'top' );
} );
/search
. I also recommend instlaling monkeyman rewrite rule analyser so that you can see what rules are loaded, what rules match a URL, and what the variables and priority will be, it takes a lot of the guessing out of things