I need to support permalink URL structure like:

http://example.com/adult-course/newyork/language-course/english/standard
http://example.com/adult-course/newyork/language-course/english/profi
http://example.com/adult-course/chicago/language-course/english/standard
http://example.com/child-course/chicago/language-course/german/standard
http://example.com/child-course/chicago/school-course/math/standard

If there would be unique slug within these links I could do something like:

add_action('init', 'custom_permastruct_rewrite');
function custom_permastruct_rewrite() {
  $wp_rewrite->add_rewrite_tag("%some_slug%", '([^/]+)', "name=");
  $wp_rewrite->add_permastruct('course_link', '/adult-course/newyork/language-course/english/%some_slug%', false);
}

…but there’s not 🙁

On the other hand, alternatively I can do something like:

add_action('init', 'custom_rewrite_basic');
function custom_rewrite_basic() {
    add_rewrite_rule( --preg_expression_here--, --redirect_address_here, 'top');
}

…which works, but the address is “rewritten” as the function name says and I get redirected from the original URL so: http://example.com/adult-course/newyork/language-course/english/standard to something like for instance http://example.com/course/my-unique-slug

Read more here: totally customizing wordpress url permalink structure, possible?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: