My question: is it possible to use WP_Rewrite so that if a URL with a custom query string (example: mysite.com/?tid=1) is placed in the address it will turn into mysite.com/1
This query refers to a second database and has nothing to do with the normal WordPress structure. Its grabbing information and populating a part of the index page.
Currently I have been able to use WP_Rewrite to do the inverse. If you go to http://www.zacharybrady.com/text/wordpress/1/ , wordpress will interpret it as http://www.zacharybrady.com/text/wordpress/?tid=1
My full code:
/*REWRITING*/
function add_rewrite_rules() {
add_rewrite_rule('([0-9]+)','index.php?tid=$matches[1]','top');
}
add_action( 'init', 'add_rewrite_rules' );
/*QUERY TAGS*/
function tid_register_rewrite_tag() {
add_rewrite_tag( '%tid%', '([0-9]+)');
}
add_action( 'init', 'tid_register_rewrite_tag');
I need to be able to do both what I have already achieved and the goal of this question. The result should be that the user never sees the query string.
I have done a lot of research but the answer to this seems to escape me.
So I kind of have an answer but its far from graceful.
On SUBMIT the form I’m using sends to a PHP script at test.php which contains the code:
And in the end this simulates the rewrite. If anyone has a more graceful way please let me know.