我在我的WP admin自定义帖子列表页面中收到以下警告(wp-admin/edit.php?post_type=video
)
Warning: Illegal offset type in isset or empty in wp-includes/post.php on line 817我正在运行WordPress v3。1.3(最新版本)。第817行为in the function
get_post_type_object()
. 搜索会发现以下线程:http://wordpress.org/support/topic/warning-illegal-offset-type-in-isset-or-empty
http://wordpress.org/support/topic/error-when-searching-for-posts-in-the-backend-illegel-offset
https://core.trac.wordpress.org/ticket/12704 - 但现在已经解决了(我运行的是v3.1.3),其中最后一篇文章写道:基本上,你有一个插件错误地注册了一个帖子类型,然后核心抱怨。据我所知,这不是核心缺陷。
我确实有一个插件(我自己的)注册了一个帖子类型,但我认为它做得很正确。
这是代码。(请注意,我最初称这些“视频”帖子,但后来将前端描述重命名为“Training Module”,但保留了原来的帖子类型名称)。
有什么问题吗?为什么我会看到警告?function video_register() { $labels = array( \'name\' => _x(\'Modules\', \'post type general name\'), \'singular_name\' => _x(\'Training Module\', \'post type singular name\'), \'add_new\' => _x(\'Add New Module\', \'video item\'), \'add_new_item\' => __(\'Add New Training Module\'), \'edit_item\' => __(\'Edit Training Module\'), \'new_item\' => __(\'New Training Module\'), \'view_item\' => __(\'View Training Module\'), \'search_items\' => __(\'Search Training Modules\'), \'not_found\' => __(\'No Training Modules found\'), \'not_found_in_trash\' => __(\'No Training Modules found in Trash\'), \'parent_item_colon\' => \'\' ); $args = array( \'labels\' => $labels, \'public\' => true, \'publicly_queryable\' => true, \'show_ui\' => true, \'query_var\' => true, \'has_archive\' => \'video\', \'menu_icon\' => \'video16x16.png\', \'rewrite\' => array(\'slug\'=>\'training\',\'with_front\'=>false), \'capability_type\' => \'post\', \'hierarchical\' => false, \'menu_position\' => \'15\', \'supports\' => array(\'title\',\'author\',\'editor\',\'custom-fields\',\'revisions\',\'comments\',\'trackbacks\'), \'taxonomies\' => array(\'category\', \'post_tag\') ); register_post_type( \'video\' , $args ); } add_action(\'init\', \'video_register\');