1

我想制作一个带有徽标和业务本身照片的业务页面。我为此使用了自定义帖子类型。但是,我无法使第二张特色图片正常工作。我想让它在没有插件的情况下工作。这是我的代码:

function create_post_type() {
    register_post_type( 
        'Bedrijven', array(
            'labels' => array(
            'name' => __( 'Bedrijven' ),
            'singular_name' => __( 'bedrijf' )
            ),
        'public' => true,
        'has_archive' => true,
        'supports' => array(
            'title',
            'editor',
            'comments',
            'excerpt',
            'thumbnail',
            'author',
            'MultiPostThumbnails',
            'page-attributes',)

        )
    );
}
add_action( 'init', 'create_post_type' );


if (class_exists('MultiPostThumbnails')) {
  new MultiPostThumbnails(array(
     'label' => 'Thumbnail Image',
     'id' => 'thumbnail-image',
     'post_type' => 'bedrijven'
   ) );
 }
4

2 回答 2

8

你可以通过这个插件简单地做到这一点: 动态特色图片

您可以通过这种方式在前端获取这些多个图像:

 if( class_exists('Dynamic_Featured_Image') ) {
    global $dynamic_featured_image;

    $featured_images = $dynamic_featured_image->get_featured_images( );
    //print_r($featured_images);

    //You can now loop through the image to display them as required
    foreach($featured_images as $featured_image) {
        echo "<img src='".$featured_image['full']."'></a>";
    }

 }
于 2014-04-02T08:15:58.513 回答
2

出色地,

一些插件可用于多个特色图像,即动态特色图像多个特色图像。您可以通过这些插件轻松管理它们。

于 2014-04-02T08:02:55.780 回答