WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

im trying to get this to work for 3 different pages

it was working fine with 1 rewrite, then when i added 2 more its not working for any of them.

heres the code:

function add_video_rewrite () 
    add_rewrite_tag("%video_id%", '([^/]*)');
    add_rewrite_tag("%video_slug%", '([^/]*)');
    add_rewrite_rule('^video/([^/]*)/([^/]*)', 'video/?video_id=$matches[1]&video_slug=$matches[2]', 'bottom');
add_action( 'init', 'add_video_rewrite' );

function add_team_rewrite () 
    add_rewrite_tag("%team_id%", '([^/]*)');
    add_rewrite_tag("%team_slug%", '([^/]*)');
    add_rewrite_rule('^videos/team/([^/]*)/([^/]*)', 'videos/?team_id=$matches[1]&team_slug=$matches[2]', 'bottom');
add_action( 'init', 'add_team_rewrite' );

function add_league_rewrite () 
    add_rewrite_tag("%league_id%", '([^/]*)');
    add_rewrite_tag("%league_slug%", '([^/]*)');
    add_rewrite_rule('^videos/league/([^/]*)/([^/]*)', 'videos/?league_id=$matches[1]&league_slug=$matches[2]', 'bottom');
add_action( 'init', 'add_league_rewrite' );
share|improve this question
up vote 1 down vote accepted

Your rewriterules arn't correct anymore. You changed

add_rewrite_rule('^video/([^/]*)/([^/]*)/[^/]*)', 'index.php?pagename=video&video_id=$matches[1]&video_src=$matches[2]&video_title=$matches[3]', 'top');


add_rewrite_rule('^video/([^/]*)/([^/]*)/[^/]*)', 'video/&video_id=$matches[1]&video_src=$matches[2]&video_title=$matches[3]', 'bottom');

The correct rewriterules for your pages are: Video

add_rewrite_rule('^video/([^/]*)/([^/]*)/[^/]*)', 'index.php?pagename=video&video_id=$matches[1]&video_src=$matches[2]&video_title=$matches[3]', 'top');


add_rewrite_rule('^videos/team/([^/]*)/([^/]*)', 'index.php?pagename=videos&team_id=$matches[1]&team_slug=$matches[2]', 'top');


add_rewrite_rule('^videos/league/([^/]*)/([^/]*)', 'index.php?pagename=videos&league_id=$matches[1]&league_slug=$matches[2]', 'top');

For team and league I assumed your WordPress page is "videos". If it is the subpage then you have to change "pagename=videos" to "pagename=videos/team" and "pagename=videos/league" in your rewriterules.

share|improve this answer
i just made your changes and it still shows "Page Not Found" when i try and visit it. yes the pages are called "video" and "videos". – scarhand Jan 21 '12 at 23:36
Did you flush your rewriterules? (go to settings > permalinks) – Rob Vermeer Jan 21 '12 at 23:37
flushing fixed it. however on the pages i now get the the error "Compilation failed: unmatched parentheses at offset 29 in /home/public_html/wp-includes/class-wp.php on line 201" – scarhand Jan 21 '12 at 23:39
I really don't know why this wouldn't work. All page get that error? – Rob Vermeer Jan 21 '12 at 23:50
no, just the ones that use the custom rewrite rule. – scarhand Jan 21 '12 at 23:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.