嗨,我有一些想法添加我也创建自定义帖子类型你需要自定义帖子类型你遵循这个代码这对我来说很有用。
// Register Custom Post Type services
function create_services_cpt() {
$labels = array(
\'name\' => _x( \'services\', \'Post Type General Name\', \'e-education\' ),
\'singular_name\' => _x( \'services\', \'Post Type Singular Name\', \'e-education\' ),
\'menu_name\' => _x( \'services\', \'Admin Menu text\', \'e-education\' ),
\'name_admin_bar\' => _x( \'services\', \'Add New on Toolbar\', \'e-education\' ),
\'archives\' => __( \'services Archives\', \'e-education\' ),
\'attributes\' => __( \'services Attributes\', \'e-education\' ),
\'parent_item_colon\' => __( \'Parent services:\', \'e-education\' ),
\'all_items\' => __( \'All services\', \'e-education\' ),
\'add_new_item\' => __( \'Add New services\', \'e-education\' ),
\'add_new\' => __( \'Add New\', \'e-education\' ),
\'new_item\' => __( \'New services\', \'e-education\' ),
\'edit_item\' => __( \'Edit services\', \'e-education\' ),
\'update_item\' => __( \'Update services\', \'e-education\' ),
\'view_item\' => __( \'View services\', \'e-education\' ),
\'view_items\' => __( \'View services\', \'e-education\' ),
\'search_items\' => __( \'Search services\', \'e-education\' ),
\'not_found\' => __( \'Not found\', \'e-education\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'e-education\' ),
\'featured_image\' => __( \'Featured Image\', \'e-education\' ),
\'set_featured_image\' => __( \'Set featured image\', \'e-education\' ),
\'remove_featured_image\' => __( \'Remove featured image\', \'e-education\' ),
\'use_featured_image\' => __( \'Use as featured image\', \'e-education\' ),
\'insert_into_item\' => __( \'Insert into services\', \'e-education\' ),
\'uploaded_to_this_item\' => __( \'Uploaded to this services\', \'e-education\' ),
\'items_list\' => __( \'services list\', \'e-education\' ),
\'items_list_navigation\' => __( \'services list navigation\', \'e-education\' ),
\'filter_items_list\' => __( \'Filter services list\', \'e-education\' ),
);
$args = array(
\'label\' => __( \'services\', \'e-education\' ),
\'description\' => __( \'post display theme services\', \'e-education\' ),
\'labels\' => $labels,
\'menu_icon\' => \'dashicons-buddicons-buddypress-logo\',
\'supports\' => array(\'title\', \'editor\', \'thumbnail\', \'revisions\', \'author\', \'trackbacks\', \'page-attributes\', \'post-formats\', \'custom-fields\'),
\'taxonomies\' => array(),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => true,
\'hierarchical\' => true,
\'exclude_from_search\' => true,
\'show_in_rest\' => true,
\'rest_base\' => \'true\',
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
);
register_post_type( \'services\', $args );
}
add_action( \'init\', \'create_services_cpt\', 0 );
此代码仔细使用服务=>;是我的自定义帖子类型e-education=>;是您替换并使用的我的“文本域”