//产品
function customer_post_product() {
$post_type = 'product';
$labels = [
'name' => '产品',
'singular_name' => '产品',
'add_new' => '添加产品',
'add_new_item' => '添加新产品',
'edit' => '修改产品',
'edit_item' => '修改产品',
'new_item' => '新产品',
'all_items' => '所有产品',
'view' => '查看产品',
'view_item' => '查看产品',
'search_items' => '搜索产品',
'not_found' => '没有该产品',
'not_found_in_trash' => '没有回收该产品',
'parent_item_colon' => '',
'menu_name' => '产品'
];
$args = [
'public' => true,
'menu_position' => 15,
'supports' => ['title', 'editor', 'comments', 'thumbnail'],
'has_archive' => true
];
customer_post_seeting( $post_type, $labels, $args );
}
//案例
function customer_post_case() {
$post_type = 'case';
$labels = [
'name' => '案例',
'singular_name' => '案例',
'add_new' => '添加案例',
'add_new_item' => '添加新案例',
'edit' => '修改案例',
'edit_item' => '修改案例',
'new_item' => '新案例',
'all_items' => '所有案例',
'view' => '查看案例',
'view_item' => '查看案例',
'search_items' => '搜索案例',
'not_found' => '没有该案例',
'not_found_in_trash' => '没有回收该案例',
'parent_item_colon' => '',
'menu_name' => '案例'
];
$args = [
'public' => true,
'menu_position' => 16,
'supports' => ['title', 'editor', 'comments', 'thumbnail'],
'has_archive' => true
];
customer_post_seeting( $post_type, $labels, $args );
}
add_action( 'init', 'customer_post_product' );
add_action( 'init', 'customer_post_case' );
function customer_post_seeting( $post_type, $labels, $args ) {
register_post_type(
$post_type,
seeting_post_args($labels, $args)
);
}
function seeting_post_labels($labels) {
$labels_arr = [
'name' => $labels['name'],
'singular_name' => $labels['singular_name'],
'add_new' => $labels['add_new'],
'add_new_item' => $labels['add_new_item'],
'edit_item' => $labels['edit_item'],
'new_item' => $labels['new_item'],
'all_items' => $labels['all_items'],
'view' => $labels['view'],
'view_item' => $labels['view_item'],
'search_items' => $labels['search_items'],
'not_found' => $labels['not_found'],
'not_found_in_trash' => $labels['not_found_in_trash'],
'parent_item_colon' => $labels['parent_item_colon'],
'menu_name' => $labels['menu_name'],
];
return $labels_arr;
}
function seeting_post_args($labels, $args) {
$args_arr = [
'labels' => seeting_post_labels($labels),
'public' => $args['public'],
'menu_position' => $args['menu_position'],
'supports' => $args['supports'],
'has_archive' => $args['has_archive'],
];
return $args_arr;
}
wordpress自定义文章
最新推荐文章于 2022-05-18 17:07:33 发布