我已经改变了你上面描述的插件自定义帖子类型。我也遇到了同样的问题,但我用这段代码解决了。
add_action('registered_post_type', 'rename_custom_post_type_name', 10, 2);
function rename_custom_post_type_name($post_type, $args) {
global $wp_rewrite;
if ($post_type == 'tour-item') { //your old slug here
$args->rewrite['slug'] = 'property'; //write your new slug here
if ( $args->has_archive ) {
$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
if ( $args->rewrite['with_front'] )
$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
else
$archive_slug = $wp_rewrite->root . $archive_slug;
add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
$feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
}
if ( $args->rewrite['pages'] )
add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
}
$permastruct_args = $args->rewrite;
$permastruct_args['feed'] = $permastruct_args['feeds'];
add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%", $permastruct_args );
}
}
由于您正在尝试更新帖子网址,因此必须在很多地方进行更改。
您的另一个问题是您希望您的类别能够正常工作,而我现在无法为您提供帮助。
希望这对您将网址更改为新网址有用。
谢谢