我正在嘗試爲自定義文章創建自定義分類。但是,當我試圖添加新的類別時,會顯示一條通知,例如「試圖獲取非對象屬性...的通知」。這是自定義代碼發佈在創建wordpress自定義分類時顯示通知
function newsbox_post() {
register_post_type('newsbox-post',
array(
'label' => __('Newsbox Post', 'text_domain'),
'labels' => array(
'name' => __('Newsbox Posts'),
'singular_name' => __('Newsbox Post'),
'menu_name' => __(' Newsbox Post', 'text_domain'),
'parent_item_colon' => __('Parent Newsbox post:', 'text_domain'),
'all_items' => __('All Newsbox post', 'text_domain'),
'view_item' => __('View Newsbox post', 'text_domain'),
'add_new_item' => __('Add New post', 'text_domain'),
'add_new' => __('New post', 'text_domain'),
'edit_item' => __('Edit post', 'text_domain'),
'update_item' => __('Update post', 'text_domain'),
'search_items' => __('Search post', 'text_domain'),
'not_found' => __('No post found', 'text_domain'),
'not_found_in_trash' => __('No post found in Trash', 'text_domain')
),
'public' => true,
'rewrite' => array('slug' => 'Newsbox-post'),
'description' => __('Enter recent to your newsbox', 'text_domain'),
'supports' => array('title', 'editor', 'page-attributes'),
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => true,
'can_export' => false,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'post'
)
);
}
add_action('init', 'newsbox_post');
這裏是自定義分類
add_action('init', 'newsbox_post_category_taxonomy', 0);
function newsbox_post_category_taxonomy() {
$labels = array(
'name' => _x('Categories', 'taxonomy general name'),
'singular_name' => _x('Categories', 'taxonomy singular name'),
'search_items' => __('Search Category'),
'all_items' => __('All Categories'),
'parent_item' => __('Parent Category'),
'parent_item_colon' => __('Parent Category:'),
'edit_item' => __('Edit Category'),
'update_item' => __('Update Category'),
'add_new_item' => __('Add New Category'),
'new_item_name' => __('New Categories Name'),
'menu_name' => __('Categories'),
);
register_taxonomy('Categories',array('newsbox-post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true
));
}
請告訴我解決方案的代碼。謝謝。
[參考? - 這是什麼錯誤PHP意味着]可能重複(http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in -php) – brasofilo 2014-09-01 15:51:18