2013-12-10 118 views
0

如何通过使用此代码添加分类? 当我点击新的分类,我得到一个错误自定义分类不工作在自定义后wordpress

function people_init() { 
    // create a new taxonomy 
    register_taxonomy(
     'people', 
     'new_post', 
     array(
      'label' => __('People'), 
      'rewrite' => array('slug' => 'person'), 
      'capabilities' => array(
       'assign_terms' => 'edit_guides', 
       'edit_terms' => 'publish_guides' 
      ) 
     ) 
    ); 
}add_action('init', 'people_init'); 

这是错误消息:

你不允许编辑这个项目。

回答

0

试试下面的代码:

function people_init() { 
// create a new taxonomy 
register_taxonomy(
    'people', 
    'new_post', 
    array(
     'label' => __('People'), 
     'rewrite' => array('slug' => 'person'), 

    ) 
); 
}add_action('init', 'people_init'); 
+0

waao .. !!它的工作很好......谢谢先生。 不同的代码有什么问题。 – user3060132

+0

此错误代码..?为什么.....。 '能力'=>数组( 'assign_terms'=> 'edit_guides', 'edit_terms'=> 'publish_guides' ) – user3060132

+0

因为你已经通过错误的参数,就可以使用像 '能力'=>数组( ' assign_terms'=>'edit_posts', 'edit_terms'=>'manage_categories' ) –

0

这是有问题的代码。删除它可以让你创建和编辑条款。

'capabilities' => array(
    'assign_terms' => 'edit_guides', 
    'edit_terms' => 'publish_guides' 
) 

能力edit_guidespublish_guides默认不存在,需要为你所选择的用户可以创建你添加它之前看到的WordPress的法典add_cap()关于如何做到这一点的详细信息。

+0

好的感谢..但能力的作用和那里的参数 – user3060132

+0

功能设置谁可以做什么。 WordPress有五个默认的“角色”,默认情况下所有角色都具有设置功能。在此实例中分配可选的自定义功能将允许您设置WP,以便只有特定用户(无论他们拥有哪个“角色”)可以为自定义分类标准创建/编辑术语。如果你没有定义能力,那么WP只使用默认值,所以任何拥有'Role''Editor'(或以上)的人都可以创建/编辑条款。查看Codex的[角色和功能](http://codex.wordpress.org/Roles_and_Capabilities)了解更多信息。 –

相关问题