我需要保存旧网站的URL,在我使用的管理wordpress中的选项permalink中
/blog/%category%/%postname%.html
我这样做是为了写博客。
But i don\'t need to get it for CPT我已经创建了CPT
function uslugi_init() {
$args = array(
\'label\' => \'Услуги\',
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'page\',
\'hierarchical\' => false,
\'rewrite\' => array(\'slug\' => \'uslugi-i-czenyi\'),
\'query_var\' => true,
\'menu_icon\' => \'dashicons-video-alt\',
\'supports\' => array(
\'title\',
\'editor\',
\'excerpt\',
\'trackbacks\',
\'custom-fields\',
\'comments\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\',)
);
register_post_type( \'uslugi\', $args );
}
add_action( \'init\', \'uslugi_init\' );
但我有一个大问题-我的CPT url是
site.com/blog/uslugi-i-czenyi/test
但我需要
site.com/uslugi-i-czenyi/test
此外,我需要从页面获取模板。。。
它可以修复吗?
How to separate CPT url from blog permalink?
请帮帮我!
SO网友:Nefro
应该有用
\'with_front\' => false,
\'
with_front\' => bool应将permalink结构与前基座连接在一起。(例如:如果permalink结构是/blog/,那么链接将是:false->/news/,true->/blog/news/)。默认为true
function uslugi_init() {
$args = array(
\'label\' => \'Услуги\',
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'page\',
\'hierarchical\' => false,
\'rewrite\' => array(\'with_front\' => false, \'slug\' => \'uslugi-i-czenyi\'),
\'query_var\' => true,
\'menu_icon\' => \'dashicons-video-alt\',
\'supports\' => array(
\'title\',
\'editor\',
\'excerpt\',
\'trackbacks\',
\'custom-fields\',
\'comments\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\',)
);
register_post_type( \'uslugi\', $args );
}
add_action( \'init\', \'uslugi_init\' );