admin管理员组文章数量:1022997
I created a one page style website that I converted to WordPress. The website include a blog, but I'm not using the usual WordPress way to display the post as I'm using a modal window appearing on click to displaying it. So basically I'm not using the Pages/Posts/Comments admin sections at all. Instead I decided to go with custom post types and create my own PHP loops. This is working pretty great for now.
But I have a problem with permalinks. Everytime I want to create a CPT, there's a permalink attributed to the "post". For example here's my CPT settings for a "carousel logo display" section (I use CPT UI plugin to create my CPTs, saying it just in case) :
"labels" => $labels,
"description" => "",
"public" => false,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => false,
"exclude_from_search" => true,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => false,
"query_var" => false,
Which is working in a way. I mean that I don't have that mywebsite/CPT_Name/blablabla/
type of links anymore. But I still have something like mywebsite/?post_type=CPT_Name&p=43
working instead (displaying my homepage), which is scary in a way.
I don't care if anyone goes on these links, because there is 0,1% of chance it happens (as of course I'll not publish/use these links at all). But I'm scared that Search engines get these permalinks in their database.
So basically, am I doing CPT the good way ? Do permalinks like the one I talked just before risks to appear on search engines ? Do I need to redirect these permalinks to my 404 page ?
Thanks a lot !
I created a one page style website that I converted to WordPress. The website include a blog, but I'm not using the usual WordPress way to display the post as I'm using a modal window appearing on click to displaying it. So basically I'm not using the Pages/Posts/Comments admin sections at all. Instead I decided to go with custom post types and create my own PHP loops. This is working pretty great for now.
But I have a problem with permalinks. Everytime I want to create a CPT, there's a permalink attributed to the "post". For example here's my CPT settings for a "carousel logo display" section (I use CPT UI plugin to create my CPTs, saying it just in case) :
"labels" => $labels,
"description" => "",
"public" => false,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => false,
"exclude_from_search" => true,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => false,
"query_var" => false,
Which is working in a way. I mean that I don't have that mywebsite/CPT_Name/blablabla/
type of links anymore. But I still have something like mywebsite/?post_type=CPT_Name&p=43
working instead (displaying my homepage), which is scary in a way.
I don't care if anyone goes on these links, because there is 0,1% of chance it happens (as of course I'll not publish/use these links at all). But I'm scared that Search engines get these permalinks in their database.
So basically, am I doing CPT the good way ? Do permalinks like the one I talked just before risks to appear on search engines ? Do I need to redirect these permalinks to my 404 page ?
Thanks a lot !
Share Improve this question edited Apr 14, 2019 at 14:15 Rojiraan asked Apr 12, 2019 at 12:43 RojiraanRojiraan 133 bronze badges1 Answer
Reset to default 0I think you should be able to set publicly_queryable
to false
, which should prevent those ugly permalinks from being generated / working.
I created a one page style website that I converted to WordPress. The website include a blog, but I'm not using the usual WordPress way to display the post as I'm using a modal window appearing on click to displaying it. So basically I'm not using the Pages/Posts/Comments admin sections at all. Instead I decided to go with custom post types and create my own PHP loops. This is working pretty great for now.
But I have a problem with permalinks. Everytime I want to create a CPT, there's a permalink attributed to the "post". For example here's my CPT settings for a "carousel logo display" section (I use CPT UI plugin to create my CPTs, saying it just in case) :
"labels" => $labels,
"description" => "",
"public" => false,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => false,
"exclude_from_search" => true,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => false,
"query_var" => false,
Which is working in a way. I mean that I don't have that mywebsite/CPT_Name/blablabla/
type of links anymore. But I still have something like mywebsite/?post_type=CPT_Name&p=43
working instead (displaying my homepage), which is scary in a way.
I don't care if anyone goes on these links, because there is 0,1% of chance it happens (as of course I'll not publish/use these links at all). But I'm scared that Search engines get these permalinks in their database.
So basically, am I doing CPT the good way ? Do permalinks like the one I talked just before risks to appear on search engines ? Do I need to redirect these permalinks to my 404 page ?
Thanks a lot !
I created a one page style website that I converted to WordPress. The website include a blog, but I'm not using the usual WordPress way to display the post as I'm using a modal window appearing on click to displaying it. So basically I'm not using the Pages/Posts/Comments admin sections at all. Instead I decided to go with custom post types and create my own PHP loops. This is working pretty great for now.
But I have a problem with permalinks. Everytime I want to create a CPT, there's a permalink attributed to the "post". For example here's my CPT settings for a "carousel logo display" section (I use CPT UI plugin to create my CPTs, saying it just in case) :
"labels" => $labels,
"description" => "",
"public" => false,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => false,
"exclude_from_search" => true,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => false,
"query_var" => false,
Which is working in a way. I mean that I don't have that mywebsite/CPT_Name/blablabla/
type of links anymore. But I still have something like mywebsite/?post_type=CPT_Name&p=43
working instead (displaying my homepage), which is scary in a way.
I don't care if anyone goes on these links, because there is 0,1% of chance it happens (as of course I'll not publish/use these links at all). But I'm scared that Search engines get these permalinks in their database.
So basically, am I doing CPT the good way ? Do permalinks like the one I talked just before risks to appear on search engines ? Do I need to redirect these permalinks to my 404 page ?
Thanks a lot !
Share Improve this question edited Apr 14, 2019 at 14:15 Rojiraan asked Apr 12, 2019 at 12:43 RojiraanRojiraan 133 bronze badges1 Answer
Reset to default 0I think you should be able to set publicly_queryable
to false
, which should prevent those ugly permalinks from being generated / working.
本文标签: Completely remove custom post type permalinks (quotOne Pagequot website)
版权声明:本文标题:Completely remove custom post type permalinks ("One Page" website) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745589265a2157788.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论