I posted this in stackoverflow as well, so hope it's good to post here as well!
I think this is my last problem to solve before everything clicks into place:
I have a homepage with a custom plugin that sends some data to another page, I am building a theme for this website that works with the plugin.
So in the theme functions.php I have added a
function myvar($vars){
$vars[] = 'ep_year';
$vars[] = 'ep_name';
return $vars;
}
add_filter('query_vars','myvar');
works a charm, I can send those values over to a custom page with a custom template assigned. This has a permalink as follows:
http://ngofwp.local/episode/
and when I send the data over it looks like so (permalinks are enabled):
http://ngofwp.local/episode/?ep_year=2011&ep_name=silly_donkey
I know I have to use an add_rewrite_rule so I've started coding that as follows:
function custom_rewrite_rule()
{
add_rewrite_rule('^episode/([^/]*)/([^/]*)\.html$','?ep_year=$matches[1]&ep_name=$matches[2]','top');
}
add_action('init', 'custom_rewrite_rule');
But now for the life of me I have no clue about the formulae to get it to work. I have read the regex rules and tested that particular rewrite on a site that helps you do that.
What I'd like it to look like is this:
http://ngofwp.local/episode/2011/silly_donkey.html
The
http://ngofwp.local/episode/
is given by wordpress's permalink setting and is a custom page in the templates folder (it displays correctly)
What did I do wrong?