我已经从WordPress复制了自定义的帖子类型代码,并对其进行了修改和添加。php但类别框在哪里。我哪儿都看不见。我也想要这个职位。
我不适合WordPress,所以请指导我解决这个问题。
谢谢:)
My Code:
function codex_custom_init() {
$labels = array(
\'name\' => \'Prices\',
\'singular_name\' => \'Price\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Price\',
\'edit_item\' => \'Edit Price\',
\'new_item\' => \'New Price\',
\'all_items\' => \'All Prices\',
\'view_item\' => \'View Price\',
\'search_items\' => \'Search Prices\',
\'not_found\' => \'No prices found\',
\'not_found_in_trash\' => \'No prices found in Trash\',
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Prices\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'price\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
register_post_type( \'price\', $args );
}
add_action( \'init\', \'codex_custom_init\' );
最合适的回答,由SO网友:Avenger 整理而成
嘿Manan试试这个代码:
function codex_custom_init() {
$labels = array(
\'name\' => \'Prices\',
\'singular_name\' => \'Price\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Price\',
\'edit_item\' => \'Edit Price\',
\'new_item\' => \'New Price\',
\'all_items\' => \'All Prices\',
\'view_item\' => \'View Price\',
\'search_items\' => \'Search Prices\',
\'not_found\' => \'No prices found\',
\'not_found_in_trash\' => \'No prices found in Trash\',
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Prices\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'price\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'taxonomies\' => array(\'category\', \'post_tag\') // this is IMPORTANT
);
register_post_type( \'price\', $args );
register_taxonomy_for_object_type(\'category\', \'price\');
}
add_action( \'init\', \'codex_custom_init\' );