WordPress add a rewrite rule to a page to accept a GET variable

Question

I want to rewrite

mysite.com/events/submission/test-event-01

to

mysite.com/events/submission?epl=test-event-01

This is what I have done so far without any result. I get a 404 error (mysite.com/events/submission/test-event-01). Can anyone suggest the correct rule?

add_action( 'init', 'epl_rewrite');
add_filter( 'query_vars', 'epl_query_vars');
        
function epl_rewrite()
{
    add_rewrite_rule('^submission/([^/]*)[/]?', 'index.php?pagename=submission&epl=$matches[1]', 'top');
}
        
function epl_query_vars( $query_vars )
{
    $query_vars[] = 'epl';
    return $query_vars;
}

Note:

  1. Permalinks are re-saved to flush the rewrite rules.
  2. mysite.com/events/submission page is already added.

Thank you in advance.

0
sariDon 6 months 2022-02-27T16:20:51-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse