2

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?

StephenB
  • 166
  • 2
  • 14
  • Yikes. This is the hard way to do this. Why wouldn't you register a custom post type along with a custom taxonomy, which gives you ALL of the beautiful SEO-friendly links built-in to WP. – random_user_name Dec 09 '16 at 23:47
  • Because it's a 3rd party API that can't be put into a custom post type. – StephenB Dec 11 '16 at 19:22

0 Answers0