Dynamic Endpoints
10up engineering best practices as a great example on how to achieve that. You basically add a new rewrite tag and a new rewrite rule and then using the template_redirect action you return your custom action. Here is the code: add_action( ‘init’, function() { add_rewrite_tag( ‘%model%’, ‘([^/]+)’ ); add_rewrite_rule( ‘cars/([^/]+)/?’, ‘index.php?model=$matches[1]’, ‘top’ ); } ); … Read more