wordpress 缩略图_如何在WordPress中添加多个帖子缩略图/特色图片

wordpress 缩略图

Recently one of our readers asked if there was a way to add multiple post thumbnails or featured images in a WordPress post. By default, most WordPress themes come with built-in support for featured images which makes adding post thumbnails really simple. However when working on custom projects, you might need to add a second featured image to a post. In this article we will show you how to add multiple post thumbnails / featured images in WordPress.

最近,我们的一位读者询问是否可以在WordPress帖子中添加多个帖子缩略图或特色图片。 默认情况下,大多数WordPress主题都内置了对特色图片的支持,这使得添加帖子缩略图非常简单。 但是,在处理自定义项目时,您可能需要在帖子中添加第二张特色图片。 在本文中,我们将向您展示如何在WordPress中添加多个帖子缩略图/特色图片。

First thing you need to do is install and activate the Multiple Post Thumbnails plugin. After activating the plugin, you need to add the following code in your theme’s functions.php file. You can add it anywhere in the file as long as you are doing it right. Read our guide on

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用 WordPress 个客户开发项目的时候,经常会碰到需要设置多个日志略图的需求,当然我们可以通过自定义字段实现,但是这样使用起来不是非常方便,没有默认的设置特色图片那么好用,这时候,我一般使用 Multiple Post Thumbnails 这个 WordPress 插件来解决。 Multiple Post Thumbnails 介绍 Multiple Post Thumbnails 是一个面向 WordPress 开发者的一个插件,它定义了一套在后台增加多个略图的机制,以及在前端调用新增略图的方法,并且它定义的后台空间支持最新的 WordPress 3.5 图片上传方式,使用起来和默认的特色图片基本一致。 Multiple Post Thumbnails:可以定义多个日志略图WordPress 插件 Multiple Post Thumbnails 使用方法 前面说过 Multiple Post Thumbnails 是一个面向开发者的插件,所以需要你对主题进行一定的修改才能使用,下面简单介绍下使用方法: 1. 上传插件并激活。  2. 如果你想给当前日志添加第二章略图,在当前主题的 functions.php 添加如下代码: if (class_exists('MultiPostThumbnails')) {     new MultiPostThumbnails(         array(             'label' => 'Secondary Image',             'id' => 'secondary-image',             'post_type' => 'post'         )     ); } 当然你可以通过将 post_type 设置为 page,给静态页面设置第二章略图,也给自定义日志类型设置。    3. 最后通过下面代码显示定义的略图: <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image'); endif; ?>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值