在创建自定义帖子类型时,我试图定义功能,但它不起作用。这个代码怎么了?
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\'),
\'capabilities\' => array(
\'edit_post\' => \'edit_video\',
\'edit_posts\' => \'edit_videos\',
\'edit_others_posts\' => \'edit_others_videos\',
\'publish_posts\' => \'publish_videos\',
\'read_post\' => \'read_videos\',
\'read_private_posts\' => \'read_private_videos\',
\'delete_post\' => \'delete_videos\'
)
);
最合适的回答,由SO网友:sorich87 整理而成
您的代码似乎是正确的。请尝试以下操作。
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\'),
\'capability_type\' => \'video\'
);
Update:
在使用members插件之前,您必须执行一些额外的步骤。请参阅JustinTadlock(members插件的开发人员)的这篇论坛帖子。
http://wordpress.org/support/topic/anyone-managed-to-get-custom-post-types-capabilities-working/page/2#post-1593534此插件似乎是自动执行的:http://wordpress.org/extend/plugins/map-cap/