Home > WordPress > 修改WordPress标签云的字体大小以及显示数量
2009March . 22nd

修改WordPress标签云的字体大小以及显示数量

如何修改Widgets标签云的字体大小?稍微研究了一下,其实很简单,还是修改代码!我就是喜欢改代码,嘎嘎~

因为是修改Widgets标签云,所以目标文件依旧是wp-includeswidgets.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来使得标签云按照标签的使用次数来排列等等。。。

  1. 2009March . 23rd - 12:47 PM
    bolo

    测试

  2. 2009March . 23rd - 12:48 PM
    bolo

    @bolo
    测试

  3. 2009June . 6th - 10:46 PM

    Hello,
    Not sure that this is true:), but thanks for a post.
    Have a nice day
    Elcoj

  4. 2009June . 21st - 1:39 PM

    正需要,测试下

  5. 2009June . 21st - 1:48 PM

    @金鱼
    嘿嘿,有空常来交流啊

  6. 2009June . 21st - 1:52 PM

    请问下2.8的标签在哪里改。在widgets.php里只能搜到以下两行相关代码:
    ‘wp_widget_tag_cloud’,
    ‘wp_widget_tag_cloud_control’,

    应该怎么改呢?谢谢

  7. 2009June . 21st - 2:36 PM

    @金鱼
    本文介绍的只是在主题模板里改的

  8. 2009June . 21st - 3:07 PM

    我的主题模板没有wp-includeswidgets.php 这个文件 改怎么改呢?@bolo

  9. 2009June . 21st - 3:09 PM

    @金鱼
    在“wp-content/theme/你的主题”目录下改

  10. 2009June . 21st - 3:51 PM

    改主题目录下的哪个文件?我是新手,很多都不懂,谢谢指导@bolo

  11. 2009June . 21st - 6:44 PM

    @金鱼
    标签云在哪个文件就改那个文件,一般是sidebar.php

  12. 2009July . 28th - 11:37 PM

    这文章我修改了,你抄的这份对2.8以后的版本无效,改一下吧,呵呵。

  13. 2009July . 29th - 7:50 AM

    @slyar
    谢谢提醒,我还没有研究过2.8版本呢

  14. 2009July . 29th - 12:40 PM

    @slyar
    我猜某人是靠搜索某关键词随意进的网站…

Subscriber selector

Close