无法看到自定义帖子类型的帖子状态下拉列表

时间:2019-09-18 作者:pixelngrain

我有一个自定义的帖子类型,叫做Group 为此,我已将所有必需的功能分配给管理员。然而,我仍然无法看到Status 编辑屏幕上的(post状态)下拉列表。

管理功能

$admin->add_cap("delete_others_{$group_cap}s");
$admin->add_cap("delete_{$group_cap}");
$admin->add_cap("delete_{$group_cap}s");
$admin->add_cap("delete_private_{$group_cap}s");
$admin->add_cap("delete_published_{$group_cap}s");
$admin->add_cap("edit_others_{$group_cap}s");
$admin->add_cap("edit_{$group_cap}");
$admin->add_cap("edit_{$group_cap}s");
$admin->add_cap("edit_private_{$group_cap}s");
$admin->add_cap("edit_published_{$group_cap}s");
$admin->add_cap("publish_{$group_cap}s");
$admin->add_cap("read_{$group_cap}");
$admin->add_cap("read_private_{$group_cap}s");
寄存器柱
public static function register_group_type()
{

    $cap_type = self::$cpt_group;
    $plural   = \'Groups\';
    $single   = \'Group\';

    $labels = [
        \'add_new\'            => esc_html__("Add New {$single}", \'group-shop\'),
        \'add_new_item\'       => esc_html__("Add New {$single}", \'group-shop\'),
        \'all_items\'          => esc_html__($plural, \'group-shop\'),
        \'edit_item\'          => esc_html__("Edit {$single}", \'group-shop\'),
        \'menu_name\'          => esc_html__($plural, \'group-shop\'),
        \'name\'               => esc_html__($plural, \'group-shop\'),
        \'name_admin_bar\'     => esc_html__($single, \'group-shop\'),
        \'new_item\'           => esc_html__("New {$single}", \'group-shop\'),
        \'not_found\'          => esc_html__("No {$plural} Found", \'group-shop\'),
        \'not_found_in_trash\' => esc_html__("No {$plural} Found in Trash", \'group-shop\'),
        \'parent_item_colon\'  => esc_html__("Parent {$plural} :", \'group-shop\'),
        \'search_items\'       => esc_html__("Search {$plural}", \'group-shop\'),
        \'singular_name\'      => esc_html__($single, \'group-shop\'),
        \'view_item\'          => esc_html__("View {$single}", \'group-shop\'),
    ];

    $labels = apply_filters(\'group_shop_group_labels\', $labels);

    $capabilities = [
        \'delete_others_posts\'    => "delete_others_{$cap_type}s",
        \'delete_post\'            => "delete_{$cap_type}",
        \'delete_posts\'           => "delete_{$cap_type}s",
        \'delete_private_posts\'   => "delete_private_{$cap_type}s",
        \'delete_published_posts\' => "delete_published_{$cap_type}s",
        \'edit_others_posts\'      => "edit_others_{$cap_type}s",
        \'edit_post\'              => "edit_{$cap_type}",
        \'edit_posts\'             => "edit_{$cap_type}s",
        \'edit_private_posts\'     => "edit_private_{$cap_type}s",
        \'edit_published_posts\'   => "edit_published_{$cap_type}s",
        \'publish_posts\'          => "publish_{$cap_type}s",
        \'read_post\'              => "read_{$cap_type}",
        \'read_private_posts\'     => "read_private_{$cap_type}s",
    ];

    $capabilities = apply_filters(\'group_shop_group_capabilities\', $capabilities);

    $rules = [
        \'ep_mask\'    => EP_PERMALINK,
        \'feeds\'      => FALSE,
        \'pages\'      => TRUE,
        \'slug\'       => esc_html__(strtolower($plural), \'group-shop\'),
        \'with_front\' => FALSE,
    ];

    $rules = apply_filters(\'group_shop_product_rules\', $rules);

    $args = [
        \'labels\'             => $labels,
        \'description\'        => __(\'Groups for the team\', \'group-shop\'),
        \'public\'             => TRUE,
        \'publicly_queryable\' => TRUE,
        \'show_ui\'            => TRUE,
        \'show_in_menu\'       => TRUE,
        \'show_in_nav_menu\'   => TRUE,
        \'show_in_rest\'       => TRUE,
        \'query_var\'          => TRUE,
        \'rewrite\'            => $rules,
        \'capability_type\'    => [$cap_type, $cap_type . \'s\'],
        \'capabilities\'       => $capabilities,
        \'has_archive\'        => TRUE,
        \'hierarchical\'       => FALSE,
        \'map_meta_cap\'       => TRUE,
        \'menu_icon\'          => \'dashicons-cart\',
        \'menu_position\'      => NULL,
        \'show_in_admin_bar\'  => TRUE,
        \'supports\'           => [\'title\', \'editor\', \'author\', \'thumbnail\'],
    ];

    $args = apply_filters(\'group_shop_product_register\', $args);

    register_post_type(strtolower(self::$cpt_group), $args);

}
图像参考-屏幕截图

enter image description here

1 个回复
SO网友:Jacob Peattie

没有一个。

在经典编辑器中,可以在“发布”框中更改帖子状态。在“状态:已发布”旁边会有一个小的“编辑”链接。

在块编辑器中,发布状态由状态中设置的日期和可见性确定(&E);“可见性”框,位于“文档”选项卡下,可以通过单击工具栏顶部的“切换到草稿”将其设置为草稿。

在任一编辑器中都没有下拉列表,只有状态列表。

相关推荐

正在尝试获取wp-includes/capabilities.php中非对象的属性

在调试中,我每分钟都会收到以下通知序列。日志:[23-Oct-2012 13:27:33 UTC] PHP Notice: Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1022 [23-Oct-2012 13:27:33 UTC] PHP Notice: Trying to get property of non-object in mysite/wp-includes/