网站地图    收藏   

主页 > 后端 > wordpress教程 >

缩略图插件WP-Thumbnails 代码调用 - WordPress

来源:自学PHP网    时间:2014-11-28 23:41 作者: 阅读:

[导读] 页面缩略图:?php if(function_exists( 39;wp_thumbnails_for_homepage 39;)) { wp_thumbnails_for_homepage( 39;width=120height=100 39;); } ?随机文章缩略图:?php if(function_exi...

缩略图插件WP-Thumbnails 代码调用

页面缩略图:

<?php if(function_exists('wp_thumbnails_for_homepage')) { wp_thumbnails_for_homepage('width=120&height=100'); } ?>

随机文章缩略图:

<?php if(function_exists('wp_thumbnails_for_random_posts')) { wp_thumbnails_for_random_posts('num=10&width=75&height=75'); } ?>

最新文章缩略图:

<?php if(function_exists('wp_thumbnails_for_recent_posts')) { wp_thumbnails_for_recent_posts('num=20&width=100&height=100'); } ?>

相关文章缩略图:

<?php if(function_exists('wp_thumbnails_for_related_posts')) { wp_thumbnails_for_related_posts('num=30&width=150&height=75'); } ?>

最热门文章缩略图,下面代码最后两个参数表示只显示视频,并且直接显示视频而不是视频中的缩略图.

<?php if(function_exists('wp_thumbnails_for_popular_posts')) { wp_thumbnails_for_popular_posts('num=100&width=150&height=75&media=video&thumb=video'); } ?>

全排列缩略图:

<?php if(function_exists('wp_thumbnails_for_single_post')) { wp_thumbnails_for_single_post('num=9&width=75&height=75'); } ?>

指定分类下的文章缩略图:

<?php if(function_exists('wp_thumbnails_for_category')) { wp_thumbnails_for_category('id=5&num=10&width=180&height=75&order=recent'); } ?>

指定标签下的文章缩略图:

<?php if(function_exists('wp_thumbnails_for_tag')) { wp_thumbnails_for_tag('id=4,5,6,7&num=10&width=180&height=75&order=random'); } ?>

短代码调用方式:

WordPress提供了短代码(short code),将短代码插入文章内部后,WordPress会自动处理短代码来实现相关功能。WP-Thumbnails也支持通过短代码让您在文章任何位置显示缩略图。短代码仅适用于各种“文章缩略图”。

比如下面的例子。请注意:短代码用中括号[ ]包起来。正式使用时,务必将下面例子中的【】替换成[ ]

随机文章缩略图:【wp-thumbnails type="random"width="75" height="75"】

最新文章缩略图:【wp-thumbnails type="recent"num="20" width="100" height="100"】

相关文章缩略图:【wp-thumbnails type="related"num="30" width="150" height="75"】

最热门文章缩略图:【wp-thumbnails type="popular"num="100" width="150" height="75"media="video" thumb="video"】

全排列缩略图:【wp-thumbnails type="single"num="9" width="75" height="75"】

指定分类下的文章缩略图:【wp-thumbnails type="category"id="5" num="10" width="180" height="75"order="recent"】

指定标签下的文章缩略图:【wp-thumbnails type="tag"num="10"  id="4,5,6,7" width="180"height="75" order="random"】

我想你已经很清楚了:短代码用中括号[ ]包起来,短代码的名称必须为wp-thumbnails,短代码必须指定是哪种类型(type)的文章缩略图(有random、recent、popular、related、single、category、tag)。

短代码中其他的参数都是可选的,这些参数和上面“带参数的调用方式”中提到的参数是完全一样的。参数之间用空格隔开,参数值用英文双引号""包围起来,各个参数的先后顺序是任意的。

没有指定的参数则采用后台相应的设置.

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论