由网站背景显示出错到标签云wp_tag_cloud源文件

GD Star Rating
loading...

今天下午6点左右,不知道我到底设置了什么,导致WP在Firefox下面的背景显示出错,找了很多方法,最终没有中我意的,只好恢复一下以前的备份,后来发表文章的时候发现,用系统自带的标签系统添加标签不行,用simple tags 的标签添加还不行,而且发表文章的时候总是提示发表不成功请重试,这让我很恼火,而且编辑文章的时候WP很慢很慢,这让我对simple tags 产生了疑问,我用这个插件很简单的理由,其实就只是想调整一下默认标签云的样式,大家都知道默认的标签云比较难看,特别是字体变大后就更不好看了,我就只想调整下字体就行了,可是按照网上说的修改模板里面sidebar.php里面的wp_tag_cloud函数里面的默认值不起作用。。。
这样我才安装了simple tags。

既然不好用,找了半天也没找到问题所在,那就只有删掉了。可删掉后默认标签云真的不好看啊。。。无奈之余我又找wp_tag_cloud相关文章,极大部分的文章都是让修改sidebar.php里面的wp_tag_cloud函数里面的默认值,对我行不通,只能另找方法,后来到了WP的官网,搜索wp_tag_cloud  后来发现了对这个函数的解释。。。其实解释我都知道的,正当我想关掉这个网页的时候发现了这个东西:

Source File

wp_tag_cloud() is located in wp-includes/category-template.php.

这是标签云函数的源文件啊,这下不愁了~~ 马上找到他,修改smallest 和largest的值,成功!!呵呵。

下面是默认的category-template

function wp_tag_cloud( $args = ” ) {
 $defaults = array(
  ‘smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt‘, ‘number’ => 45,
  ‘format’ => ‘flat’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’,
  ‘exclude’ => ”, ‘include’ => ”, ‘link’ => ‘view’, ‘taxonomy’ => ‘post_tag’, ‘echo’ => true
 );

 

这是我修改后的

function wp_tag_cloud( $args = ” ) {
 $defaults = array(
  ‘smallest’ => 13, ‘largest’ => 18, ‘unit’ => ‘px‘, ‘number’ => 45,
  ‘format’ => ‘flat’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’,
  ‘exclude’ => ”, ‘include’ => ”, ‘link’ => ‘view’, ‘taxonomy’ => ‘post_tag’, ‘echo’ => true
 );

我仅仅就修改了字体的大小还有单位。

下面是网上的中文解释

标准语法:

<?php wp_tag_cloud(”); ?>

带参数:

<?php wp_tag_cloud(’number=30&smallest=12&largest=12&unit=px’); ?>

详细参数及说明:

  • smallest:标签文字最小字号,默认为8pt;
  • largest:标签文字最大字号,默认为22pt;
  • unit:标签文字字号的单位,默认为pt,可以为px、em、pt、百分比等;
  • number:调用的标签数量,默认为45个,设置为“0”则调用所有标签;
  • format:调用标签的格式,可选“flat”、“list”和“array”,默认为“flat”平铺,“list”为列表方式;
  • orderby:调用标签的排序,默认为“name”按名称排序,“count”则按关联的文章数量排列;
  • order:排序方式,默认为“ASC”按正序,“DESC”按倒序,“RAND”按任意顺序。
  • exclude:排除部分标签,输入标签ID,并以逗号分隔,如“exclude=1,3,5,7”不显示ID为1、3、5、7的标签;
  • include:包含标签,与exclude用法一样,作用相反,如“include=2,4,6,8”则只显示ID为2、4、6、8的标签。

另外再附上官网的原版英文解释

Default Usage

 <?php $args = array(
    
'smallest' => 8
    
'largest' => 22,
    
'unit' => 'pt'
    
'number' => 45,  
    
'format' => 'flat',
    
'orderby' => 'name'
    
'order' => 'ASC',
    
'exclude' =>  
    
'include' => 
    
'link' => 'view'
    
'taxonomy' => 'post_tag'
    
'echo' => true ); ?>

By default, the usage shows:

  • smallest – The smallest tag (lowest count) is shown at size 8
  • largest – The largest tag (highest count) is shown at size 22
  • unit – Describes ‘pt’ (point) as the font-size unit for the smallest and largest values
  • number – Displays at most 45 tags
  • format – Displays the tags in flat (separated by whitespace) style
  • orderby – Order the tags by name
  • order – Sort the tags in ASCENDING fashion
  • exclude – Exclude no tags
  • include – Include all tags
  • link – view
  • taxonomy – Use post tags for basis of cloud
  • echo – echo the results

Parameters

smallest 
(integer) The text size of the tag with the smallest count value (units given by unit parameter).
largest 
(integer) The text size of the tag with the highest count value (units given by the unit parameter).
unit 
(string) Unit of measure as pertains to the smallest and largest values. This can be any CSS length value, e.g. pt, px, em, %; default is pt (points).
number 
(integer) The number of actual tags to display in the cloud. (Use ‘0’ to display all tags.)
format 
(string) Format of the cloud display.

  • 'flat' (Default) tags are separated by whitespace
  • 'list' tags are in UL with a class=’wp-tag-cloud’
  • 'array' tags are in an array and function returns the tag cloud as an array for use in PHP Note: the array returned, rather than displayed, was instituted with Version 2.5.
orderby 
(string) Order of the tags. Valid values:

  • 'name' (Default)
  • 'count'
order 
(string) Sort order. Valid values – Must be Uppercase:

  • 'ASC' (Default)
  • 'DESC'
  • 'RAND' tags are in a random order. Note: this parameter was introduced with Version 2.5.
exclude 
(string) Comma separated list of tags (term_id) to exclude. For example, ‘exclude=5,27’ means tags that have the term_id 5 or 27 will NOT be displayed. Defaults to exclude nothing.
include 
(string) Comma separated list of tags (term_id) to include. For example, ‘include=5,27’ means tags that have the term_id 5 or 27 will be the only tags displayed. Defaults to include everything.
link 
(string) Set link to allow edit of a particular tag. Note: this parameter was introduced with Version 2.7. Valid values:

  • 'view' (Default)
  • 'edit'
taxonomy 
(string) Taxonomy to use in generating the cloud. Note: this parameter was introduced with Version 2.8.

  • 'post_tag' – (Default) Post tags are used as source of cloud
  • 'category' – Post categories are used to generate cloud
  • 'link_category' – Link categories are used to generate cloud
echo 
(boolean) Show the result or keep it in a variable. The default is true (display the tag cloud). Note: this parameter was introduced with Version 2.8. Valid values:

  • 1 (true) – default
  • 0 (false)

 下面是修改后的字体,只是没有原来那种两种字体大小差别很大而已。

111

已有3条评论 发表评论

  1. sky /

    没有遇到过,不过留个醒好了

    GD Star Rating
    loading...
  2. 网络推广 /

    :(24): 支持一下

    GD Star Rating
    loading...
  3. shuxiong /

    :(23): :(18): :(8): :(24):

    GD Star Rating
    loading...

回复给shuxiong 取消回复