为什么特色图片没有显示在我的自定义帖子类型中?

时间:2012-05-11 作者:Ryan

我在我的函数中添加了缩略图支持。php

// Add Thumbnail Support
add_theme_support(\'post-thumbnails\');
set_post_thumbnail_size( 140, 140, true );
我用

// Create Custom Post Type for Work
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type( \'custom_post\',
    array(
        \'thumbnail\',
        \'labels\' => array(
            \'name\' => __( \'Custom\' ),
            \'singular_name\' => __( \'Custom\' )
        ),
        \'public\' => true,
        \'has_archive\' => true,
        \'rewrite\' => array(\'slug\' => \'custom\'),
        \'taxonomies\' => array(\'category\', \'post_tag\')
    )
  );
}
但是,当我在自定义帖子类型中创建新帖子时,不会显示特色图片元框。我还尝试在声明自定义帖子类型时使用数组,如下所示,但这也不起作用

// Add Thumbnail Support
add_theme_support(\'post-thumbnails\', array (\'post\',\'work\',\'custom_post\'));
set_post_thumbnail_size( 140, 140, true );
我错过了什么?

3 个回复
最合适的回答,由SO网友:Milo 整理而成

尝试register_post_type supports 参数:

\'supports\' => array( \'thumbnail\' )

SO网友:kevin

将此参数添加到数组中:

\'supports\' => array(\'thumbnail\'),
编辑:米洛跑得更快。

SO网友:Muhammad Sadiq

试试这个它对我有用。。。。。

add_theme_support(\'post-thumbnails\');
add_post_type_support( \'my_product\', \'thumbnail\' );    
function create_post_type() {
        register_post_type( \'my_product\',
            array(
                \'labels\' => array(
                    \'name\' => __( \'Products\' ),
                    \'singular_name\' => __( \'Product\' )
                ),
                \'public\' => true,
                \'has_archive\' => true
            )
        );
    }
    add_action( \'init\', \'create_post_type\' );

结束

相关推荐

Anonymous functions usage

只是想知道使用匿名函数的首选方法是什么。首先,我有一些这样的代码:function page_columns( $columns ) { $columns = array( \'cb\' => \'<input type=\"checkbox\" />\', \'title\' => \'Title\', \'author\' => \'Author\', \'te