Wordpress - 将特色图片添加到自定义帖子类型

问题描述 投票:4回答:5

我正在尝试为我的主题添加一个特色图片,但不是为帖子或页面添加 - 我创建了一个名为Properties的自定义类型(它用于房地产代理),因此我如何启用特色图片,因为它没有出现在sceen选项?

希望有人能提供帮助,

$property  = new Cuztom_Post_Type( 'Property', array(
    'supports' => array('title', 'editor')
));
wordpress wordpress-plugin wordpress-theming
5个回答
13
投票
$property  = new Cuztom_Post_Type( 'Property', array(
    'supports' => array('title', 'editor', 'thumbnail')
));

我似乎已经解决了我自己的问题 - 见上文


6
投票

这可能对某人有帮助,

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' );

0
投票

这可能会有所帮助

    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' );

0
投票

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' );

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' );
© www.soinside.com 2019 - 2024. All rights reserved.