Background
I have a a page called 'listen' with a custom template, which runs a custom wp_query that uses the 'show' variable in the URL. The following example works...
example.com/listen/?show=thebigshow
What I Want
I want to be able to get rid of the ?show= part of the url, and format it as follows...
example.com/listen/thebigshow
What I've Tried
I have tried implementing the following rewrite rule, but to no avail.
function add_query_vars_filter( $vars ){
$vars[] = "show";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );
function listen_rewrite_action() {
add_rewrite_tag('%show%','([^/]*)');
add_rewrite_rule(
'^listen/([^/]+)$',
'/listen/?show=$matches[1]',
'top'
);
}
add_action( 'init', 'listen_rewrite_action' );
A Bit More Information
Rewrite Rules (as previewed in a plugin)
What .htaccess looks like after generation
Thanks, Andy.
$after
parameter tobottom
and flush again.