我用这个密码解决了问题;
add_filter(\'post_type_link\', function($link, $post){
if ($post->post_type != \'episode\')
return $link;
if ($cats = get_post_meta($post->ID, \'serie_slug\', true))
$link = str_replace(\'%serie%\', $cats, $link);
return $link;
}, 10, 2);
add_action(\'init\', function(){
$args = array(
.
.
\'rewrite\' => array( \'slug\' => \'series\' ),
.
.
);
register_post_type(\'series\', $args);
$args = array(
.
.
\'rewrite\' => array( \'slug\' => \'series/%series%\', \'with_front\'
.
.
);
register_post_type(\'episodes\', $args);
flush_rewrite_rules();
});
您必须添加
serie_slug
(必须与剧集的后期元数据同名)。您可以手动或使用元数据库来执行此操作。