add_rewrite_rule not loading correct page nor getting variables

This seems to work!

?post_type=directors&name=$matches[1] seems to be the key

add_rewrite_rule( 'directors/([^/]*)/showreels/([^/]*)/video/([^/]*)/?', 'index.php?post_type=directors&name=$matches[1]&showreel=$matches[2]&video=$matches[3]', 'top' );

so final code now;

function wpse13483_init() {

    add_rewrite_rule( 'directors/([^/]*)/showreels/([^/]*)/video/([^/]*)/?', 'index.php?post_type=directors&name=$matches[1]&showreel=$matches[2]&video=$matches[3]', 'top' );

}
add_action( 'init', 'wpse13483_init' );

function wpa52794_query_vars( $vars) {
    $vars[] = 'video';
    $vars[] = 'showreel';

    return $vars;
}
add_filter( 'query_vars', 'wpa52794_query_vars' );

Leave a Comment