wordpress如何使用特色图像功能,wordpress文章缩略图的调用
2013-04-19 14:56
881 查看
自从2.9版本以来,wordpress引入了特色图像功能,如果你的wordpress主题支持该功能,那么使用特色图像将可以很方便地在首页、分类页等列表页面显示指定的文章缩略图。
如果你使用的wordrpress主题没有特色图片功能,可以通过以下方法设置。
1、在主题文件夹下的functions.php文件中加入代码:
2、发布文章时,在上传图像时设置特色图像。
3、在需要显示特色图像的地方插入以下代码:
4、特色图像缩略图尺寸参数设置:修改以上the_post_thumbnail(); 的参数即可。
其中 thumbnail、medium、large的默认尺寸在后台-设置-媒体中定义。
如果你使用的wordrpress主题没有特色图片功能,可以通过以下方法设置。
1、在主题文件夹下的functions.php文件中加入代码:
if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); }
2、发布文章时,在上传图像时设置特色图像。
3、在需要显示特色图像的地方插入以下代码:
<?php if ( has_post_thumbnail()) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php the_post_thumbnail(); ?> </a> <?php endif; ?>
4、特色图像缩略图尺寸参数设置:修改以上the_post_thumbnail(); 的参数即可。
the_post_thumbnail('thumbnail'); // 小缩略图 (默认 150px x 150px ) the_post_thumbnail('medium'); // 中缩略图 (默认 300px x 300px )-自适应图像比例 the_post_thumbnail('large'); // 大缩略图 (默认 640px x 640px )-自适应图像比例 the_post_thumbnail('full'); // 完整尺寸 the_post_thumbnail( array(100,100) ); // 自定义
其中 thumbnail、medium、large的默认尺寸在后台-设置-媒体中定义。
相关文章推荐
- 黄聪:如何使用WordPress 2.9内置文章缩略图功能(Post Thumbnail)
- 黄聪:如何不用插件使用代码调用Wordpress中的随机文章。
- 如何设置WordPress文章特色图像(Featured Image)
- wordpress3.8之文章自定义栏目功能的使用
- 使用 WordPress 自定义字段功能为文章添加下载按钮
- wordpress如何添加调用侧边栏小工具功能
- 如何使用单元测试 测试WEB组件方法中的含有Session、Cookie等HttpContext功能调用的方法?[转载]
- Wordpress中文章的特色图像Featured Image究竟存在哪里?
- wordpress文章缩略图的使用
- zen-cart如何调用wordpress中的文章
- 织梦首页如何调用带缩略图的文章
- wordpress 文章缩略图功能
- WordPress 获取文章内容页特色图像地址
- WordPress自动提取文章第一张图为特色图像
- WordPress使用自定义字段设置缩略图和显示作者文章数量和评论数量代码
- wordpress如何调用评论文章最多的方法
- wordpress使用timthumb和七牛云存储函数实现缩略图功能
- 易企建站系统如何调用wordpress最新文章?
- 黄聪:WordPress添加“特色图片”功能并调用
- wordpress文章特色图片功能详解