P粉267885948 2023-08-09 11:35:09 0 1 152
[PHP讨论组] 举报 回复话题 ↕
/blog/%postname%/
/blog/new-post-type
/blog/
www.website.com/name-of-page/
1
0
分享
P粉476883986 已被采纳 2023-08-10 10:28:03 1楼
register_post_type()函数的rewrite参数有一个with_front参数,当设置为false时,不会在固定链接结构中加上前缀。
register_post_type()
rewrite
with_front
false
register_post_type( 'cpt', array( 'rewrite' => array( 'with_front' => false, ) );
上述代码将阻止CPT的帖子URL中出现/blog/,但我不知道那是否意味着URL将在根目录下工作。
赞 +0 添加回复
P粉476883986 已被采纳 2023-08-10 10:28:03 1楼
register_post_type()
函数的rewrite
参数有一个with_front
参数,当设置为false
时,不会在固定链接结构中加上前缀。上述代码将阻止CPT的帖子URL中出现
/blog/
,但我不知道那是否意味着URL将在根目录下工作。 赞 +0 添加回复