因此,我的目标是找到一种方法,只为自定义文章类型添加更多缩略图,例如,我希望有一个大图像(不是相同的图像)用于特色文章和默认视图的不同图像。
因此,我的目标是找到一种方法,只为自定义文章类型添加更多缩略图,例如,我希望有一个大图像(不是相同的图像)用于特色文章和默认视图的不同图像。
你试过这个吗?add_image_size
为什么不用自定义文章模板插件呢?
我从网上找到了一个解决方案。我还自定义了一些代码。你可以检查一下。
步骤1:从链接下载这个库,并放在functions.php
旁边(主题根目录)。
步骤2:将以下代码复制到functions.php
中。
/*
* Code for Multiple Featured Image.
* Multiple Featured image is only for your selected post type.
*/
require_once('library/multi-post-thumbnails.php');
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(array(
'label' => '2nd Feature Image',
'id' => 'feature-image-2',
'post_type' => 'your_post_type_name'
)
);
new MultiPostThumbnails(array(
'label' => '3rd Feature Image',
'id' => 'feature-image-3',
'post_type' => 'your_post_type_name'
)
);
new MultiPostThumbnails(array(
'label' => '4th Feature Image',
'id' => 'feature-image-4',
'post_type' => 'your_post_type_name'
)
);
};