I have the following code that exists in a plugin that is meant to take a request to the url /stores/directory/foorbar/
and pass foobar
as a GET variable:
function pcrr_rewrite_rules($a) {
$k = array('stores/directory/([^/]+)/?$' => 'index.php?pagename=directory&pod_store_id=$matches[1]');
return $k + $a;
}
add_filter('rewrite_rules_array', 'pcrr_rewrite_rules');
# Flush existing rules and rewrite
function pcrr_activate() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
register_activation_hook(__FILE__, 'pcrr_activate');
The expected behaviour would be any requests to /stores/directory/foobar/
would instead load index.php?...
, however, whilst requests are being handled, they are redirecting to the URL, instead of masking it. For example, a request to /stores/directory/foobar/
is redirected to /stores/directory/
.
Any ideas on how I can correct this behaviour?
Cheers!
Quick’n’dirty Class to do this following below (you need to flush by hand in admin settings for permalinks):
Note: Just written off the backside of my brain, so no waranty on anything. Typos & such may be hidden in there.