ZenOven's Archivers

From zenoven on 2009-08-21 00:31:57

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

今天下午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’); ?>
详细参数及说明:


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

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:


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.

orderby  (string) Order of the tags. Valid values:

order  (string) Sort order. Valid values - Must be Uppercase:

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:

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

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:


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

<img class="alignnone size-full wp-image-122" title="111" src="http://www.zenoven.com/wp-content/2009/08/111.jpg" alt="111" width="287" height="95" />

查看完整版本: 由网站背景显示出错到标签云wp_tag_cloud源文件

From shuxiong on 2009-12-28 20:03:47

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

From 网络推广 on 2010-06-17 20:14:25

:(24): 支持一下

From sky on 2010-12-30 18:56:09

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

Tags: wp_tag_cloud, 出错, 标签云, 背景


©ZenOven