最后我用了这样的东西-
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_rewrite_rule( \'directors/([^/]*)/showreels/([^/]*)/\', \'index.php?post_type=directors&name=$matches[1]&showreel=$matches[2]\', \'top\' );
add_rewrite_rule( \'directors/([^/]*)/photography/?\', \'index.php?post_type=directors&name=$matches[1]&photography=1\', \'top\' );
}
add_action( \'init\', \'wpse13483_init\' );
function wpa52794_query_vars( $vars) {
$vars[] = \'video\';
$vars[] = \'showreel\';
$vars[] = \'photography\';
return $vars;
}
add_filter( \'query_vars\', \'wpa52794_query_vars\' );
然后,要获取页面上的var-
$show_photograpy = get_query_var( \'photography\');
$selected_playlist = get_query_var( \'showreel\');
这很有效。唯一恼人的是url结构和链接被xml站点地图插件忽略,因此只有在手动创建结构时,才存在带有变量的链接。。
ie
$url="/directors/".$video_directors[\'director_names\'][0].\'/showreels/\'.$video_directors[\'showreel_sections\'][0].\'/video/\'.$vid_id.\'/\';