2015-02-10 131 views
0

它很简单,我认为,但我没有找到任何关于它..我想为我的三个职位类型的功能缩略图,我请你们帮助我。功能缩略图为特定的自定义帖子类型

add_theme_support('post-thumbnails', array('crew', 'staff' , 'guest')); 

add_action('init', 'create_post_type'); 

function create_post_type() { 
register_post_type('crew', 
    array(
     'labels' => array(
     'name' => __('Crew'), 
     'singular_name' => __('Crew')), 
     'public' => true, 
     'has_archive' => true, 
     'rewrite' => array('slug' => 'crew') 
    ) 
); 

register_post_type('staff', 
    array(
     'labels' => array(
     'name' => __('Staff'), 
     'singular_name' => __('Staff')), 
     'public' => true, 
     'has_archive' => true, 
     'rewrite' => array('slug' => 'staff') 
    ) 
); 

register_post_type('guest', 
    array(
     'labels' => array(
     'name' => __('Gast'), 
     'singular_name' => __('Gast')), 
     'public' => true, 
     'has_archive' => true, 
     'rewrite' => array('slug' => 'guest') 
    ) 
); 
} 

我觉得没有真的多说,它可能很为你们很简单....

回答

0

您需要定义特征图像的支持,所以以后每次添加以下行所有自定义帖子类型的数组。

'supports' => array('title', 'editor', 'author', 'thumbnail', 'sticky') 

您当然可以删除或添加您需要或不需要的功能。查看代码中的所有支持:http://codex.wordpress.org/Function_Reference/register_post_type#Arguments

+0

非常感谢!绝对完美! – 2015-02-10 16:32:44

0

您需要在每个帖子类型中添加一个'supports'行,以便WP知道每个帖子允许使用哪些功能。

使用你的例子应该是这样的,以支持特色照片:

add_action('init', 'create_post_type'); 

function create_post_type() { 
register_post_type('crew', 
    array(
     'labels' => array(
     'name' => __('Crew'), 
     'singular_name' => __('Crew')), 
     'public' => true, 
     'has_archive' => true, 
     'rewrite' => array('slug' => 'crew') 
    ), 
    'supports' => array('title', 'editor', 'excerpt', 'custom-fields', 'thumbnail') 
); 

register_post_type('staff', 
    array(
     'labels' => array(
     'name' => __('Staff'), 
     'singular_name' => __('Staff')), 
     'public' => true, 
     'has_archive' => true, 
     'rewrite' => array('slug' => 'staff') 
    ), 
    'supports' => array('title', 'editor', 'excerpt', 'custom-fields', 'thumbnail') 
); 

register_post_type('guest', 
    array(
     'labels' => array(
     'name' => __('Gast'), 
     'singular_name' => __('Gast')), 
     'public' => true, 
     'has_archive' => true, 
     'rewrite' => array('slug' => 'guest') 
    ), 
    'supports' => array('title', 'editor', 'excerpt', 'custom-fields', 'thumbnail') 
); 
} 

删除此行:

add_theme_support('post-thumbnails', array('crew', 'staff' , 'guest')); 
+0

差不多,不过谢谢你! – 2015-02-10 16:32:27

相关问题