0
votes

I've add a custom post type with custom taxonomies. I've also added rewrite rules in order to handle following urls:

courses/languages/english/english-course

where courses is the base slug, languages and english are taxonomy slugs and english-course is my custom post. english-course is a child taxonomy of languages and english-course has been categorized in english-course. My rewrite rule is:

courses/(.+)/(.+)/(.+)/?$  => index.php?thr_course=$matches[3]

Everything works fine but any categories are permitted using this syntax. All following urls are legitimate and work as well:

  1. courses/languages/french/english-course
  2. course/products/english/english-course
  3. course/anycategory/anycategory2/english-course

My rewrite rule is pretty obvious: it only matches my post name ignoring which categories it belongs to. Where and how should I implement a check in order to return 404 if post exists but parent taxonomies are wrong?

1

1 Answers

0
votes

I think WordPrss will not give you a solution for your customization automatically. Fetch other parameters from like parent / child category from URL, similar to thr_course parameter. Use this parameter in your query to narrow down your result.

Hope this will help you.