I've been wracking my brain with this problem for the past couple of days, looking over all the potential solutions with no success.
Here's what I'm trying to do. I want to create an SEO friendly url for pages that are created from an API. I have created a page called Book Online which lists categories of what they offer: Spa, Acupuncture, and whatnot. When they click on that category, I want it to look like /book-online/category/Spa/. Where /category/ is a child page of Book Online.
BUT, I have to pass Spa's ID and an authentication token.
add_rewrite_rule(
'^book-online/category/([^/]*)/?', 'index.php?catID=$matches[1]&catname=$matches[2]&token=$matches[3]',
'top'
);
function add_query_vars_filter( $vars ){
$vars[] = "catID";
$vars[] = "catname";
$vars[] = "token";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );
I have checked the wp_rewrite rules and I can see that it has been added to the rules, but it's not generating. Can anyone help me?