Let us say that I have a form to search by multiple tags in wordpress.
<input type="checkbox" name="my_tags[]" value="tag1" />
<input type="checkbox" name="my_tags[]" value="tag2" />
I want to make it so that when my plugin sees that my_tags[] is set, it rewrites the request to say
mysite.com/?tag=tag1+tag2
I know to use add_query_arg to put in the tag, and to use the query_vars filters to allow my arguments to be sent, but what do i hook into to get the arguments that were sent after the request, but before wp parses the request?
My understanding is that you wouldn’t really be ‘replacing’ the query in the current request, but rather forming a new request URI and redirecting the client with
wp_redirect()with the default302 Foundstatus code. Something like:This sort of housecleaning has to happen before headers are sent, obviously. A logical place to hook it in through the Plugin API would be the
parse_requestorsend_headersactions. I mean, all you’re doing here is parsing a request and sending headers. 😛I know nearly nothing about doing this with a server rewrite in the .htaccess file, though, so maybe you might explore that as well.