问题描述

我已经注册了以下的帖子类型 –

$holidayLabels = array(
    'name' => __( 'Holidays'),
    'singular_name' => __( 'Holidays'),
    'all_items' => __( 'All Holidays'),
    'add_new' => __( 'Add New Holiday'),
    'add_new_item' => __( 'Add New Holiday'),
    'edit_item' => __( 'Edit Holiday'),
    'new_item' => __( 'New Holiday'),
    'view_item' => __( 'View Holidays'),
    'not_found' => __( 'No Holidays found'),
    'not_found_in_trash' => __( 'No Holidays found in Trash'),
    'parent_item_colon' => ''

);

$holidayArgs = array(
    'labels'               => $holidayLabels,
    'public'               => true,
    'publicly_queryable'   => true,
    '_builtin'             => false,
    'show_ui'              => true,
    'query_var'            => true,
    'rewrite'              => array( "slug" => "holidays" ),
    'capability_type'      => 'post',
    'hierarchical'         => false,
    //'menu_position'        => 6,
    'supports'             => array( 'title'),
    'has_archive'          => false,
    'show_in_nav_menus'    => false,

);
register_post_type('holidays', $holidayArgs);

当我发布新假期或开始编辑现有的假期时,我想删除标题下方的固定链接。

我想删除这个,因为假期将显示在单独的窗口小工具中。我不希望管理员能够看到它作为单一的帖子无论如何。没有为此定义模板。

最佳解决方案

那还有另一种方法。更好,我猜。

你应该看看 register_post_type 参数。你应该这样设置它们:

'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

如果帖子类型不是公开的,那么你将看不到这部分编辑器。

参考文献

注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。