gpt4 book ai didi

php - 删除自定义帖子类型的 URL 结构

转载 作者:行者123 更新时间:2023-12-02 17:41:47 24 4
gpt4 key购买 nike

我想知道是否可以删除自定义帖子类型的 URL 结构。例如,我有 2 种自定义帖子类型:投资组合和 slider 。

我想保留这样的投资组合帖子类型的 URL 结构:mysite.com/portfolio/item-1 等。

但我不想要 slider 帖子的 URL 结构,因为 slider 只会显示在主页上,我不希望访问者能够通过访问 mysite.com/slider/slide-1 来访问它。可能吗?

提前致谢:)

WordPress 论坛帖子:http://wordpress.org/support/topic/no-url-structure-for-custom-post-type-1?replies=1

最佳答案

当您注册新的自定义帖子时,您正在使用 register post type , 正确的?有选项

'rewrite'            => false,
'query_var' => false,
'publicly_queryable' => false,
'public' => false

在 WordPress 文档之后:

rewrite Triggers the handling of rewrites for this post type. To prevent rewrites, set to false.

query_var 'false' - Disables query_var key use. A post type cannot be loaded at /?{query_var}={single_post_slug}

publicly_queryable Whether queries can be performed on the front end as part of parse_request().

public 'false' - Post type is not intended to be used publicly and should generally be unavailable in wp-admin and on the front end unless explicitly planned for elsewhere.

现在转到永久链接设置,不做任何更改 - 保存更改。它将重建您的“路由”。

这样的设置将从前端禁用您的自定义帖子。

关于php - 删除自定义帖子类型的 URL 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19747096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com