頁面縮略圖:
<?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)。
短代碼中其他的參數都是可選的,這些參數和上面“帶參數的調用方式”中提到的參數是完全一樣的。參數之間用空格隔開,參數值用英文雙引號""包圍起來,各個參數的先后順序是任意的。
沒有指定的參數則采用后臺相應的設置.
新聞熱點
疑難解答
圖片精選