有些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转载请注明,肆意删除链接,我们将保留追责权利