2010-11-29 208 views
1

我想创建一个名为testimonials的自定义帖子类型,为此我想让管理员有机会添加公司名称/用户名以及他们提供了哪些推荐,我知道我可以做到这一点通过在我的functions.php文件中声明一个自定义的帖子类型,但它似乎不工作,我得到的只是普通的帖子字段,有人可以告诉我哪里出错了,或者我该怎么做?自定义帖子类型wordpress

function testimonials_register() { 
$args = array(
    'label' => __('Testimonials'), 
    'singular_label' => __('Testimonial'), 
    'public' => true, 
    'show_ui' => true, 
    'capability_type' => false, 
    'hierarchical' => false, 
    'rewirte' => true, 
    'supports' => array('title', 'editor') 
); 

register_post_type('testimonial', $args); 
} 

回答

0

您拼写重写错误,对于初学者。

0

您缺少add_action('init', 'testimonials_regiser');的功能。

更透彻的代码,更重要的一点定制可以如下:

function testimonials_register() { 
$labels = array(
'name'    => _x('Testimonials', 'post type general name'), 
'singular_name'  => _x('Testimonial', 'post type singular name'), 
'add_new'   => _x('Add New', 'testimonial'), 
'add_new_item'  => __('Add New Testimonial'), 
'edit_item'   => __('Edit Testimonial'), 
'new_item'   => __('New Testimonial'), 
'all_items'   => __('All Testimonials'), 
'view_item'   => __('View Testimonial'), 
'search_items'  => __('Search Testimonials'), 
'not_found'   => __('No testimonials found'), 
'not_found_in_trash' => __('No testimonials found in the Trash'), 
'parent_item_colon' => '', 
'menu_name'   => 'Testimonial' 
); 
$args = array(
'labels'  => $labels, 
'description' => '', 
'public'  => true, 
'menu_position' => 5, 
'supports'  => array('title', 'editor'), 
'has_archive' => true, 
); 
register_post_type('testimonial', $args); 
} 
add_action('init', 'testimonials_register'); 

这里是一个很好guide

相关问题