我希望这不仅仅是我这方面输入错误的结果,但如果是,我不会看到它。
我正在向我的网站添加自定义帖子类型。实际上我加了三个。其中两个我正在尝试为新的用户类别设置自定义功能。
在我的管理面板中,当我将下面的代码功能块添加到我的主题函数中时,我无法将其注册。php文件。然而,我注释掉了所有与功能相关的变量,新的CPT在管理界面中显示得很好。如果我取消注释任何与功能相关的变量,CPT不会显示在我的管理菜单中。
还有一点信息。我有一个测试页面,我正在自定义post类型的属性上运行var转储,以查看它是否注册。当我使用功能集注册CPT时,虽然它不显示为菜单项,或者不允许我访问该特定CPT的编辑器(因此它似乎没有设置),但它仍然显示在我的var转储中,并且正在为该特定CPT设置功能。
这是我的代码:
function nb_register_assignment_CPT() {
/*
Assignment CPT
*/
$nb_assignment_labels = array(
\'name\' => _x(\'Assignments\', \'post type general name\', \'doula\'),
\'singular_name\' => _x(\'Assignment\', \'post type singular name\', \'doula\'),
\'add_new\' => _x(\'Add New\', \'assignment\', \'doula\'),
\'add_new_item\' => __(\'Add New Assignment\', \'doula\'),
\'edit_item\' => __(\'Edit Assignment\', \'doula\'),
\'new_item\' => __(\'New Assignment\', \'doula\'),
\'all_items\' => __(\'All Assignments\', \'doula\'),
\'view_item\' => __(\'View Assignment\', \'doula\'),
\'search_items\' => __(\'Search Assignments\', \'doula\'),
\'not_found\' => __(\'No assignments found\', \'doula\'),
\'not_found_in_trash\' => __(\'No assignments found in Trash\', \'doula\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => __(\'Assignments\', \'doula\')
);
$nb_assignment_args = array(
\'labels\' => $nb_assignment_labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => _x( \'assignment\', \'URL slug\', \'doula\' ) ),
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => 52,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\' ),
\'capability_type\' => array( \'assignment\', \'assignments\' ),
\'capabilities\' => array(
\'publish_posts\' => \'publish_assignments\',
\'edit_posts\' => \'edit_assignments\',
\'edit_others_posts\' => \'edit_others_assignments\',
\'delete_posts\' => \'delete_assignments\',
\'delete_others_posts\' => \'delete_others_assignments\',
\'read_private_posts\' => \'read_private_assignments\',
\'edit_post\' => \'edit_assignment\',
\'delete_post\' => \'delete_assignment\',
\'read_post\' => \'read_assignment\'
),
\'map_meta_cap\'=> true
);
register_post_type(\'assignment\', $nb_assignment_args);
}
感谢您的关注。