I’m trying to create a new endpoint using add_rewrite_endpoint()
. Here’s my code:
// Add query var.
add_filter( 'query_vars', function( $vars ) {
$vars[] = 'my-endpoint';
return $vars;
} );
// Add endpoint.
add_action( 'init', function() {
add_rewrite_endpoint( 'my-endpoint', EP_AUTHORS );
} );
I can now visit example.com/author/my-endpoint which is great but “sub” endpoints also seem to work. For example:
- example.com/author/my-endpoint/random
- example.com/author/my-endpoint/anything-here
How can I create my endpoint without also creating these “sub” endpoints?