我已经创建了一个自定义帖子,如下所示。它在我的后端管理面板中显示正常,但是当我去查看帖子时,它是空的。有关我的一个自定义帖子,请参阅here。我是否错过了告诉wordpresshwo显示字段的内容?
add_action('init', 'give_gnt_register');
function give_gnt_register() {
$labels = array(
'name' => _x('Offered items'),
'singular_name' => _x('Item'),
'add_new' => _x('Give an item away'),
'add_new_item' => __('Give a new item away'),
'edit_item' => __('Edit item'),
'new_item' => __('Give Item Away'),
'view_item' => __('View Item'),
'search_items' => __('Search Offered Items'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => array('category'),
'supports' => array('title','thumbnail', 'custom-fields','comments')
);
register_post_type( 'give' , $args );
}
答案 0 :(得分:0)
add_action('init', 'give_gnt_register');
function give_gnt_register() {
wp_create_category('Give');
$labels = array(
'name' => _x('Offered items'),
'singular_name' => _x('Item'),
'add_new' => _x('Give an item away'),
'add_new_item' => __('Give a new item away'),
'edit_item' => __('Edit item'),
'new_item' => __('Give Item Away'),
'view_item' => __('View Item'),
'search_items' => __('Search Offered Items'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => array('category'),
'supports' => array('title','thumbnail', 'custom-fields','comments')
);
// create "give" post type
register_post_type('give', $args);
}
我只需添加wp_create_category
。