Lượt xem | |
Hiện tại: | |
1h trước: | |
24h trước: | |
Tổng số: |
Đây là đoạn code đăng ký post type chuẩn giúp chúng ta copy để bỏ vào dự án một cách nhanh nhất
add_action( 'init', function() { register_post_type( 'news', [ 'labels' => [ 'name' => __( 'News Item', ABC ), 'singular_name' => __( 'News Item', ABC ), 'menu_name' => __( 'News Items', ABC ), 'name_admin_bar' => __( 'News Items', ABC ), 'add_new' => __( 'Add News Item', ABC ), 'add_new_item' => __( 'Add News Item', ABC ), 'edit_item' => __( 'Edit News Item', ABC ), 'new_item' => __( 'New News Item', ABC ), 'all_items' => __( 'All News Items', ABC ), 'view_item' => __( 'View News Items', ABC ), 'search_items' => __( 'Search News Items', ABC ), 'not_found' => __( 'No News Items', ABC ), 'not_found_in_trash' => __( 'No News Items found in Trash', ABC ), 'parent_item_colon' => '', 'menu_name' => __( 'News', ABC ), ], 'has_archive' => true, 'public' => true, 'publicly_queryable' => true, 'supports' => [ 'title', 'author' ], 'exclude_from_search' => false, 'capability_type' => 'post', 'rewrite' => [ 'slug' => 'news' ], 'menu_icon' => 'dashicons-megaphone', // NOTE: For a full (searchable) list, see wp-includescssdashicons.css 'menu_position' => 4 ]); });
2016-12-22 07:00:05
Nguồn: http://fcwordpress.net/code-dang-ky-post-type-chuan.html