Javascript WordPress在自定义帖子类型子帖子中为childs url自定义JS路由

Javascript WordPress在自定义帖子类型子帖子中为childs url自定义JS路由,javascript,wordpress,Javascript,Wordpress,我添加了一个JS路由器(),并且喜欢在Costum Post类型的帖子上使用它。但我不能让它工作 我喜欢工作的url结构如下: /[CTP]/[post_title]/[JS router] function paper_post_type() { register_post_type('paper', [ 'labels' => array ( 'name' => 'Paper',

我添加了一个JS路由器(),并且喜欢在Costum Post类型的帖子上使用它。但我不能让它工作

我喜欢工作的url结构如下:
/[CTP]/[post_title]/[JS router]

function paper_post_type() {
    register_post_type('paper',
        [
            'labels' => array (
                'name' => 'Paper',
                'menu_name' => 'Paper',
            ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'capability_type' => 'post',
            'hierarchical' => true,
            'rewrite' => true,
            'has_archive' => false
        ]
    );
}
add_action('init', 'paper_post_type');

add_action('init', function() {
    add_rewrite_rule( 
        '^paper/([^/]+)/?$',
        'index.php?paper=$matches[1]',
        'top'
    );
});
这项工作:

add_action('init', function() {
    add_rewrite_rule('^paper/([^/]*)/', 'index.php?paper=$matches[1]', 'top');
});