我已经使用以下内容在自定义post类型上设置了自定义分类法:(为了举例说明,自定义post类型被称为newtype
新的分类法叫做newtax
.
// Create Custom Post Type for newpost
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type( \'x_newtype\',
array(
\'labels\' => array(
\'name\' => __( \'New Type\' ),
\'singular_name\' => __( \'New Type\' )
),
\'public\' => true,
\'has_archive\' => true,
\'rewrite\' => array(\'slug\' => \'newtype\'),
\'taxonomies\' => array(\'category\', \'post_tag\'),
\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'thumbnail\')
)
);
}
// Add custom field for custom post type
function new_taxonomy() {
register_taxonomy(
\'newtax\',
\'x_newtype\',
array(
\'hierarchical\' => true,
\'label\' => \'New Tax\',
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => \'newtax\')
)
);
}
add_action( \'init\', \'new_taxonomy\' );
这很好,但我有一个关于URL重定向的问题。
当前,如果您转到http://www.domain.com/newtype/newtax-term/post-name/
它将重定向到http://www.domain.com/newtype/post-name/
. 允许的最佳方式是什么http://www.domain.com/newtype/newtax-term/post-name/
加载而不重定向?
感谢阅读。