歡迎來(lái)到合肥浪訊網(wǎng)絡(luò)科技有限公司官網(wǎng)
  咨詢服務(wù)熱線:400-099-8848

知識(shí)付費(fèi)和直播可能就是泡沫

發(fā)布時(shí)間:2015-04-04 文章來(lái)源:  瀏覽次數(shù):3123
看到良多博客都有標(biāo)簽聚合的功能,于是花了點(diǎn)兒時(shí)間找了找,找到了這個(gè)方法。

下面和大家共享下:


首先復(fù)制一份你博客主題的page.php模板


然后在其頂部加入


<?php
/*
Template Name: Tags
*/
?>


然后將這種顯示正文內(nèi)容的代碼換成調(diào)用tags的代碼


<?php the_content(); ?>


換成


<?php wp_tag_cloud(‘smallest=12&largest=18&unit=px&number=0&orderby=count&order=DESC’);?>


在style.css里面增加如下代碼可以使得間距更好看:


#page-cnt.tags,
#page-cnt.friends { height: 576px; padding: 6px 0 0; overflow: hidden; line-height: 30px; }
#page-cnt.tags,
#page-cnt.friends { height: auto; padding-top: 5px; overflow: visible; }
.tags a { display: inline-block; margin: 0 4px; white-space: nowrap; }


打開(kāi)主題中的functions.php文件,在最末真?zhèn) ?>前面添加下面的代碼,就可以實(shí)現(xiàn)彩色標(biāo)簽云了:


;
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);


大功告成,在后臺(tái)新建一個(gè)tags頁(yè)面就可以了。

上一條:80后為互聯(lián)網(wǎng)人群借款主...

下一條:必要商城,你這黑公關(guān)做的...