2012-07-31 232 views
4

早上好。如何将自定义字段添加到自定义帖子类型?

我创建了一个名为'产品'的自定义帖子类型。我想创建一个自定义字段(metabox 正确的字词?),我的客户可以在此框中打勾以确定此 CPT中的给定帖子是否为精选帖子。

这里是我的functions.php代码来创建的“产品” CPT:

function products_custom_init() { 

    $labels = array(
     'name' => _x('Products', 'post type general name'), 
     'singular_name' => _x('Product', 'post type singular name'), 
     'add_new' => _x('Add New', 'products'), 
     'add_new_item' => __('Add New Product'), 
     'edit_item' => __('Edit Product'), 
     'new_item' => __('New Product'), 
     'view_item' => __('View Product'), 
     'search_items' => __('Search Products'), 
     'not_found' => __('Nothing found'), 
     'not_found_in_trash' => __('Nothing found in Trash'), 
     'parent_item_colon' => '' 
    ); 

    $args = array(
     'labels' => $labels, 
     'public' => true, 
     'publicly_queryable' => true, 
     'show_ui' => true, 
     'show_in_menu' => true, 
     'show_in_nav_menus' => false, 
     'query_var' => true, 
     'rewrite' => array('slug','pages'), 
     'capability_type' => 'post', 
     'hierarchical' => true, 
     'menu_position' => 5, 
     'supports' => array('title','editor','thumbnail','excerpt',) 
    ); 

    register_post_type('products' , $args); 
} 
add_action('init', 'products_custom_init'); 

所以,我该怎么办的“特色” metabox /自定义字段添加到产品的帖子?

非常感谢,

辛西娅

回答

相关问题