12

テーマに注目の画像を追加しようとしていますが、投稿やページには追加していません-プロパティ(不動産業者向け)というカスタムタイプを作成しました。表示されないので、注目の画像を有効にするにはどうすればよいですか。画面オプションで?

誰かが助けてくれることを願っています、

$property  = new Cuztom_Post_Type( 'Property', array(
    'supports' => array('title', 'editor')
));
4

6 に答える 6

22
$property  = new Cuztom_Post_Type( 'Property', array(
    'supports' => array('title', 'editor', 'thumbnail')
));

私は自分の質問を解決したようです-上記を参照してください

于 2012-09-22T15:36:37.383 に答える
7

これは誰かを助けるかもしれません、

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' );
于 2015-12-08T09:57:05.103 に答える
3

テーマのfunction.phpファイルの次のコード行を使用して、任意のカスタム投稿タイプのサポート投稿サムネイルを有効にすることができます。

add_post_type_support( 'forum', 'thumbnail' );

注:ここで、forumは投稿タイプ名です。

このコードをafter_setup_themeフックに保持できます。

于 2020-06-25T20:32:54.100 に答える
2

おそらくこれは役立つでしょう

    function create_post_type() {
  register_post_type( 'sadaf_films',
    array(
      'labels' => array(
        'name' => __( 'Films' ),
        'singular_name' => __( 'Film' )
      ),
      'public' => true,
      'has_archive' => true,
      'supports' => array( 'title', 'editor', 'custom-fields','thumbnail' ),
    )
  );
}
add_action( 'init', 'create_post_type' );
于 2018-07-15T11:01:52.700 に答える
2

このコードを100%使用する

 add_theme_support('post-thumbnails');
add_post_type_support( 'news', 'thumbnail' ); 

function create_posttype() {
    register_post_type( 'news',
        array(
            'labels' => array(
                'name' => __( 'News' ),
                'singular_name' => __( 'news' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'news'),
            'menu_icon' => 'dashicons-format-aside',

        )
    );
}
add_action( 'init', 'create_posttype' );
于 2019-03-28T11:55:12.193 に答える
0
    add_theme_support('post-thumbnails');
    add_post_type_support( 'testimonial', 'thumbnail' );

    function create_posttype() {
     register_post_type( 'testimonial',
        array(
                'labels' => array(
                    'name' => __( 'Testimonial' ),
                    'singular_name' => __( 'testimonial' )
                ),
                'public' => true,
                'has_archive' => true,
                'rewrite' => array('slug' => 'testimonial'),
                // add category in custom post type
                'taxonomies' => array( 'category'),
            )
        );
    }

    add_action( 'init', 'create_posttype' );
于 2019-04-25T12:07:27.583 に答える