如何从自定义帖子类型的帖子中隐藏永久链接部分?

时间:2015-02-24 13:03:32

标签: wordpress custom-post-type permalinks posts

我想隐藏Wordpress中特定帖子类型的帖子标题下的永久链接部分。我怎么能这样做?

2 个答案:

答案 0 :(得分:9)

register_post_types下添加以下参数:

'public' => false,  // it's not public, it shouldn't have it's own permalink, and so on
'publicly_queryable' => true,  // you should be able to query it
'show_ui' => true,  // you should be able to edit it in wp-admin
'exclude_from_search' => true,  // you should exclude it from search results
'show_in_nav_menus' => false,  // you shouldn't be able to add it to menus
'has_archive' => false,  // it shouldn't have archive page
'rewrite' => false,  // it shouldn't have rewrite rules

您需要的是第一个元素'public' => false

答案 1 :(得分:0)

我们找不到像“标题”“内容编辑器”等删除“slug”这样的过滤器或选项。

我们需要通过CSS管理它。通过研究高级自定义字段(ACF),他们做同样的事情。 他们在代码中放置 display:none

您只需将下面的代码放在style.css中:

.post-type-<post type slug> #edit-slug-box {
display: none;
}