本文标签: wordpress
标签云彩色显示设置:
在模版的functions.php文件最后添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php function colorCloud($text) { //用正则表达式搜索和替换标签内容 $text = preg_replace_callback('|<a (.+?)>|i', 'colorCloudCallback', $text); return $text; } function colorCloudCallback($matches) { $text = $matches[1]; $color = dechex(rand(0,16777215)); $pattern = '/style=(\'|\")(.*)(\'|\")/i'; $text = preg_replace($pattern, "style=\"color:#{$color};$2;\"", $text); return "<a $text>"; } //添加过滤器 add_filter('wp_tag_cloud', 'colorCloud', 1); ?> |
标签云字体大小设置方法:
打开 wp-includes/category-template.php 搜索 wp_tag_cloud 找到
‘smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45,‘format’ => ‘flat’, ‘separator’ => “\n”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’,
具体的参数说明:
1. smallest – 定义标签的最小字号,默认为 8;
2. largest – 定义标签的最大字号,默认为 22;
3. unit – 设置字号类型,如 “pt” 或 “px” 等,默认为 “pt” 类型;
4. number – 设置标签云数量,默认显示 45 个标签;
5. orderby – 设置按 “name” 或 “count” 排序,默认为 “name” 方式;(注:orderby=count 表示按照标签使用次数排列)
6. order – 设置按 “DESC” 或 “ASC” 升降序排列,默认为 “ASC” 升序。
声明: 本文由( liva )原创编译,转载请保留链接: wordpress 标签云彩色显示以及字体大小设置
- 上一篇:给wordpress增加阅读次数 无插件
- 下一篇:吐槽下BackLinks
wordpress 标签云彩色显示以及字体大小设置:等您坐沙发呢!
发表评论
