0

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' );

1 Answer 1

1

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');

To

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');

Team

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

League

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.

8
  • 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
    Commented Jan 21, 2012 at 23:36
  • Did you flush your rewriterules? (go to settings > permalinks) Commented Jan 21, 2012 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
    Commented Jan 21, 2012 at 23:39
  • I really don't know why this wouldn't work. All page get that error? Commented Jan 21, 2012 at 23:50
  • no, just the ones that use the custom rewrite rule.
    – scarhand
    Commented Jan 21, 2012 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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