Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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

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.

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
show 3 more comments

Your Answer

 
discard

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.