有些WordPress主題使用的是WordPress自帶的标簽雲小工具,預設的顯示個數、字型大小、排序等也許不能滿足你的需求,好在WordPress提供了 widget_tag_cloud_args 這個 filter可以修改預設的參數。 在你目前主題的 functions.php 檔案添加下面的代碼即可:
- //custom widget tag cloud
- add_filter( 'widget_tag_cloud_args', 'theme_tag_cloud_args' );
- function theme_tag_cloud_args( $args ){
- $newargs = array(
- 'smallest' => 8, //最小字号
- 'largest' => 22, //最大字号
- 'unit' => 'pt', //字号機關,可以是pt、px、em或%
- 'number' => 45, //顯示個數
- 'format' => 'flat',//清單格式,可以是flat、list或array
- 'separator' => "\n", //分隔每一項的分隔符
- 'orderby' => 'name',//排序字段,可以是name或count
- 'order' => 'ASC', //升序或降序,ASC或DESC
- 'exclude' => null, //結果中排除某些标簽
- 'include' => null, //結果中隻包含這些标簽
- 'link' => 'view' //taxonomy連結,view或edit
- 'taxonomy' => 'post_tag', //調用哪些分類法作為标簽雲
- );
- $return = array_merge( $args, $newargs);
- return $return;
- }
- 本文版權歸屬:甯波哲宇網絡公司http://www.netzheyu.com/aboutseo/show_27.html轉載請注明,肆意删除連結,我們将保留追責權利