我们目前正在开发一个新的wp主题,所有当前的帖子都转移到一个名为products的新CPT。对于SEO,需要保留产品的链接。
该职位类型的当前结构为:
www.url。com/category-a/category-b/productname
将项目从默认帖子类型移动到新的CPT后,URL如下所示:
www.url。com/products/productname
但我们希望保留这些职位的默认职位结构。归档页面显示产品,因此工作正常。
我的永久链接设置为:
/%类别%/%pagename%
因此,我们基本上想要改变:www.url.com/products/productname
收件人:www.url.com/category-a/subcategory-a/productname
这是我们创建的CPT:
function cptui_register_my_cpts_producten() {
/**
* Post Type: Producten.
*/
$labels = array(
"name" => __( "Producten", "sage" ),
"singular_name" => __( "Product", "sage" ),
"archives" => __( "Producten Archief", "sage" ),
);
$args = array(
"label" => __( "Producten", "sage" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => array( "slug" => "producten", "with_front" => false ),
"query_var" => true,
"supports" => array( "title", "editor", "thumbnail" ),
"taxonomies" => array( "category" ),
);
register_post_type( "producten", $args );
}
add_action( \'init\', \'cptui_register_my_cpts_producten\' );