2012-02-10 31 views
6

Có cách nào để tạo loại bài đăng tùy chỉnh với các danh mục riêng biệt trong wordpress không?Loại riêng biệt cho các loại bài đăng

Ví dụ:

bài viết kiểu "Tin tức" nên có loại "Thế giới" và "Local". bài viết kiểu "Sản phẩm" nên có categories: "Software" và "phần cứng" và tôi không muốn có tùy chọn để thiết lập "Software" Đến "Tin tức" bài kiểu.

Có cách nào để xử lý việc này không?

+0

Tin tưởng người chỉnh sửa của bạn có thực sự cần mức độ chi tiết đó không? – thenetimp

Trả lời

12

Bạn có thể tạo kiểu bài tùy chỉnh bằng cách làm theo mã ví dụ:

function ts_post_type_test() { 
    register_post_type('Test', 
       array( 
       'label' => __('Test'), 
       'public' => true, 
       'show_ui' => true, 
       'show_in_nav_menus' => false, 
       'menu_position' => 5, 
       'capability_type' => 'post', 
       'texonomies' => array('category'), 
       'supports' => array('title','editor','thumbnail'), 
       ) 
    ); 
} 

liên kết trang web wordpress: http://codex.wordpress.org/Function_Reference/register_post_type

Đối với Tạo danh mục riêng cho bài đặc biệt sử dụng sau đây liên kết:

http://codex.wordpress.org/Function_Reference/register_taxonomy

Mã ví dụ:

register_taxonomy('name of taxonomy', 'post name',array("hierarchical" => true,"label" => "Label Category","singular_label" => "label of taxonomy",'update_count_callback' => '_update_post_term_count','query_var' => true,'rewrite' => array('slug' => 'slug name of new registered taxonomy', 'with_front' => false),'public' => true,'show_ui' => true,'show_tagcloud' => true,'_builtin' => false,'show_in_nav_menus' => false)); 
Các vấn đề liên quan