doudang9147 2015-10-29 17:06
浏览 52
已采纳

如何在Wordpress博客中使用特色图像中的不同缩略图?

On a Wordpress site I am maintaining, the client wants to have a different header image for the blog post than what appears in the thumbnail on the blog roll page and wherever the thumbnail to the blog post appears on the site.

Right now it seems that the featured image is used for both the header image and the thumbnail.

Is there a way where these images can be different?

Any help is appreciated, thanks!

  • 写回答

1条回答 默认 最新

  • dqqxkq4047 2015-10-29 17:19
    关注

    If you do this through your theme files or if you develop a plugin, it is not easy to explain it here. But you can use a plugin and do this easily. 1. "Multiple Post Thumbnails" plugin. Install this on your site ( or download this file and include it on your functions.php file https://github.com/voceconnect/multi-post-thumbnails/blob/master/multi-post-thumbnails.php ) and add following code to use another post image.

    if (class_exists('MultiPostThumbnails')) {
        new MultiPostThumbnails(
            array(
                'label' => 'Secondary Image',
                'id' => 'secondary-image',
                'post_type' => 'post'
            )
        );
    }
    

    After that you can call for images using,

    get_the_post_thumbnail($post_type, $thumb_id, $post_id, $size, $attr, $link_to_original);
    

    And also you can use add_image_size( $size_id, $width, $height, $hard_crop ); function to specify the size of the image.

    1. "Advanced Custom Field" Plugin Using this plugin you can do many more things. And you can add any numbers of post thumbnails using this. And almost all the other custom input types can be easily add to your theme.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊