修改WordPress标签云的字体大小以及显示数量
文章作者:Slyar 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作。
恩,有朋友问到如何修改Widgets标签云的字体大小,稍微研究了一下,发现很简单,还是修改代码!我就是喜欢改代码,嘎嘎~
因为是修改Widgets标签云,所以目标文件依旧是\wp-includes\widgets.php,打开并搜索wp_tag_cloud,这个就是标签云的调用函数了,查了一下参数表,得到wp_tag_cloud函数的参数如下:
smallest – Adjusts the size of the smallest tags in the cloud. Default is "8".
largest – Adjusts the size of the biggest tags in the cloud. Default is "22".
unit – Sets the unit type for font size (i.e. point or em). Default is "pt".
number – How many tags will display in the cloud. Default is "45".
format – "Flat" displays an inline cloud with each term separated by whitespace. "List" generates an unordered list. "Array" lets you define an array of tags. Default is "flat".
orderby – Sort the cloud by "name" or "count". Default is "name".
order – Sort the cloud in ascending or descending order. Default is "ASC".
这样结果就很明了了,如果要修改字体的大小,只要把 wp_tag_cloud(); 修改为 wp_tag_cloud('unit=px&smallest=8&largest=20'); 即可,其中:
unit=px是字体大小的单位,使用我们熟悉的px最好;
smallest=8是指最小字体大小,自己修改;
largest=20是指最大字体大小,自己修改。
还可以使用number=45来设置标签的显示数量,orderby=count来使得标签云按照标签的使用次数来排列等等。。。
好了,关于标签云函数Slyar就介绍到这里,大家自己发挥呵呵。
您可能还对以下内容感兴趣
收藏、分享这篇文章! 用 RSS feed 订阅本博客 什么是订阅? Trackback评论
18 条评论 关于 “修改WordPress标签云的字体大小以及显示数量”
发表您的评论[审核后显示]












坐个沙发!
不错,我就差个标签云了,先拷贝下了! :)辛苦了!
我记得我是用某个插件实现的效果……改代码,很怕的是换主题,哎
囧rz...我改别的就忘记改这个。。。受教了
Slyar 我又学了一招,呵呵~
不行呀,我改为 wp_tag_cloud('unit=px&smallest=8&largest=18'); 怎么没效果呀,调整
Slyar 回复 于 08月 27th, 2008 23:34:
你改的幅度大点试试。。。
我突然想起你这个方法是针对侧栏的标签修改,我的标签是显示在左侧的也就是内容板块下面的~
Slyar 回复 于 08月 28th, 2008 13:28:
汗。。。那你找相应的模板改就行了嘛。。。
呵呵,就是这句
'number=200' 替换下就好了~~
不行,加进去限制数量吧,要不太多了不好~
Slyar 回复 于 08月 28th, 2008 16:02:
用number参数不是就可以?
是的已经加好~
咦,真的上面三个都可不写吗?
我想问一下,你用的是什么评论插件来的?
Slyar 回复 于 08月 28th, 2008 18:54:
我没用评论插件啊,WP自带的。
咦,自带的可以显示评论内容吗?要修改主题以外的文件吧?
我用自带的却是“ 某某 on 日志名字”
请教
Slyar 回复 于 08月 28th, 2008 19:11:
你说侧边栏啊,那个是插件,我把那个中文工具箱里面的东西给截取出来了。
[...] 在Slyar的blog上看到相关的一篇文章修改WordPress标签云的字体大小以及显示数量介绍到标签云的一系列参数,顺便也转录过来了: smallest – Adjusts the size of the smallest tags in the cloud. Default is “8″. largest – Adjusts the size of the biggest tags in the cloud. Default is “22″. unit – Sets the unit type for font size (i.e. point or em). Default is “pt”. number – How many tags will display in the cloud. Default is “45″. format – “Flat” displays an inline cloud with each term separated by whitespace. “List” generates an unordered list. “Array” lets you define an array of tags. Default is “flat”. orderby – Sort the cloud by “name” or “count”. Default is “name”. order – Sort the cloud in ascending or descending order. Default is “ASC”. [...]
学习了,谢谢分享