Php 自定义帖子类型URL重定向错误

Php 自定义帖子类型URL重定向错误,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,我有一些Wordpress CPT。他们正确的URL应该是/wordpress/training/training page/,这是我在管理页面中看到的URL,但当我单击链接时,我最终得到的URL是/wordpress/blog/2010/05/21/training page/ 我停用了我的插件,但没有成功。有人知道如何保持正确的URL完整吗 这是我的密码: <?php add_action( 'init', 'tv_content_posttype' ); function tv_co

我有一些Wordpress CPT。他们正确的URL应该是/wordpress/training/training page/,这是我在管理页面中看到的URL,但当我单击链接时,我最终得到的URL是/wordpress/blog/2010/05/21/training page/

我停用了我的插件,但没有成功。有人知道如何保持正确的URL完整吗

这是我的密码:

<?php
add_action( 'init', 'tv_content_posttype' );
function tv_content_posttype() {
register_taxonomy('content', 
    'training',
    array(
        'hierarchical' => true,
        'label' => 'Content Index',
        'query_var' =>  true, 
        'rewrite' => true
    )
);

register_post_type( 'training',
    array(
        'type' => 'page',
        'labels' => array(
            'name' => __( 'TV Training' ),
            'singular_name' => __( 'TV Training' )
        ),
        'public' => true,
        'rewrite' => array(
            'with_front' => false,
            'slug' => 'training',
        ),
        'hierarchical' => true,
        'query_var' => true,
        'taxonomies' => array( 'content' ),
    )
);
}

只是一些观察:对于
register\u post\u type()。其次,
'with_front'=>false
告诉WordPress URL结构应该是
/training/training page/
<代码>/wordpress/
在本演示文稿中,是您告诉它停止的“前面”部分。此外,您不需要为post_类型添加“分类法”,但需要在注册分类法之前注册post类型。所以试试这个:

<?php
add_action( 'init', 'tv_content_posttype' );
function tv_content_posttype() {
register_post_type( 'training',
    array(
        'labels' => array(
            'name' => __( 'TV Training' ),
            'singular_name' => __( 'TV Training' )
        ),
        'public' => true,
        'rewrite' => array(
            'with_front' => true,
            'slug' => 'training',
        ),
        'hierarchical' => true,
        'query_var' => true,
    )
);

register_taxonomy('content', 
    'training',
    array(
        'hierarchical' => true,
        'label' => 'Content Index',
        'query_var' =>  true, 
        'rewrite' => true
    )
);

}