注册分类$args->分类中提供的参数无效

时间:2013-07-18 作者:Franz Noel

我在我的register_post_type(). 然后,我在插件上实现了分类法。其中,分类法中的$参数如下所示:

$args = array(
  \'label\'=>\'Partner Type\',
  \'labels\' => array(
    \'name\' => __(\'Partners\'),
    \'singular_name\' => __(\'Partner Type\'),
    \'menu_name\' => __(\'Partner Types\'),
    \'all_items\' => __(\'All Partner Types\'),
    \'edit_item\' => __(\'Edit Partner Type\'),
    \'view_item\' => __(\'View Partner Type\'),
    \'update_item\' => __(\'Update Partner Type\'),
    \'add_new_item\' => __(\'Add New Partner Type\'),
    \'new_item_name\' => __(\'NEw Item Type\'),
    \'parent_item\' => __(\'Parent Type\'),
    \'parent_item_colon\' => __(\'Parent Partner Colon\'),
    \'search_items\' => __(\'Search Partner\'),
    \'popular_items\' => __(\'Popular Partner Type\'),
    \'separate_items_with_commas\' => __(\'Separate partner types with commas\'),
    \'add_or_remove_items\' => __(\'Add or Remove Partner Types\'),
    \'choose_from_most_used\' => __(\'Choose from Most Used Partner Type\'),
    \'not_found\' => __(\'Partner Type Not Found\'),
  ),
  \'hierarchical\' => true,
);
register\\u taxonomy(\'partner\\u taxonomy\',\'partners\',$args);

$args英寸post_type 包含:

\'taxonomies\' => \'partner_taxonomies\',
然后,我得到了错误

为/var/www/html/stecLive/wp includes/post中的foreach()提供的参数无效。php在线1346

其中代码说明:

foreach ( $args->taxonomies as $taxonomy ) {
  register_taxonomy_for_object_type( $taxonomy, $post_type );
}
我不认为“分类法”是register_taxonomy(). 您将如何为“分类法”使用或提供数组?或者换句话说,我做错了什么?

1 个回复
SO网友:Franz Noel

我现在明白了。。。

“分类法”中的错误属于register_post_type() 作用它不属于register_taxonomy(). 在内部声明“分类法”的正确方式register_post_type() 是:

\'taxonomies\' => array(\'partner_type_taxonomies\'),

结束

相关推荐