I have this form:
<form action="<?php the permalink(); ?>" method="get" >
<input type="hidden" name="taxo" value="question" />
<select name = "cata">
<option value="unique_name-a">xxx</option>
<option value="foo">yyy</option>
<option value="bar">zzz</option>
</select>
<select name ="catb">
<option value="unique_name-d">xxx</option>
<option value="unique_name-e">yyy</option>
<option value="unique_name-f">zzz</option>
</select>
<!-- and more select -->
<button>send</button>
</form>
And this query in a template page:
$query = new WP_Query( array(
'post_type' => 'page',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'question', // from $_GET['taxo']
'field' => 'slug',
'terms' => array('unique_name-a','unique_name-e','more'), // from my submit form
'include_children' => false,
'operator' => 'AND'
),
)
) );
I would like to play with URL rewriting. I have something like:
http://example.com/?taxo=question&cata=foo&catb=bar&catc=more
I would like the rewritten URL for the above query to be:
http://example.com/questions/cata/foo/catb/bar/catc/…/
EDIT: Why this function is not working?
function custom_rewrite() {
add_rewrite_rule(
'question-tax/test/4/',
'index.php?tax=question&test=4',
'top'
);
}
// refresh/flush permalinks in the dashboard if this is changed in any way
add_action( 'init', 'custom_rewrite' );