嗯,我使用了一些不同类型的代码,可以定制帖子,但它工作得很好。其中保存标签、类别、自然图像。这里是代码,希望能对您有所帮助。
function my_custom_post_faq() {
$labels = array(
\'name\' => _x( \'Slides\', \'post type general name\' ),
\'singular_name\' => _x( \'Slides\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New\', \'Slides\' ),
\'add_new_item\' => __( \'Add New Slide\' ),
\'edit_item\' => __( \'Edit Slide\' ),
\'new_item\' => __( \'New Slide\' ),
\'all_items\' => __( \'All Slides\' ),
\'view_item\' => __( \'View Slides\' ),
\'search_items\' => __( \'Search Slides\' ),
\'not_found\' => __( \'No Slide found\' ),
\'not_found_in_trash\' => __( \'No Sliode found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Slide\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Holds our Slides and Slide specific data\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'has_archive\' => true,
);
register_post_type( \'faq\', $args );
}
add_action( \'init\', \'my_custom_post_faq\' );
/*----------- For tags -------------*/
function my_taxonomies_faq() {
$args = array();
register_taxonomy( \'faq_category\', \'faq\', $args );
}
add_action( \'init\', \'my_taxonomies_faq\', 0 );
/*----------- For categories -------------*/
function my_taxonomies_faq_cat() {
$labels = array(
\'name\' => _x( \'FAQ Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'FAQ Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search FAQ Categories\' ),
\'all_items\' => __( \'All FAQ Categories\' ),
\'parent_item\' => __( \'Parent FAQ Category\' ),
\'parent_item_colon\' => __( \'Parent FAQ Category:\' ),
\'edit_item\' => __( \'Edit FAQ Category\' ),
\'update_item\' => __( \'Update FAQ Category\' ),
\'add_new_item\' => __( \'Add New FAQ Category\' ),
\'new_item_name\' => __( \'New FAQ Category\' ),
\'menu_name\' => __( \'FAQ Categories\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
);
register_taxonomy( \'faq_category\', \'faq\', $args );
}
add_action( \'init\', \'my_taxonomies_faq_cat\', 0 );