不用插件实现 WordPress彩色标签云

侧边栏的标签云(Tag Cloud)一直是 WordPress 2.3+ 以后的内置功能,一般直接调用函数 wp_tag_cloud 或者在 Widgets 里开启即可,但是默认的全部是一个颜色,只是大小不一样,很是不顺眼,虽然可以用 Simple Tags 之类的插件,但是总感觉不爽,所以我介绍一个不用任何插件就能显示彩色标签云的方法。
方法是 Alex 那里看来的

后台编辑 主题 的 functions.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);

颜色是随机的,可以自行修改 $color = dechex(rand(0,16777215)); 这行来修改范围,这样就很炫耀。。。。

然后在侧边栏 sidebar.php 里调用如下代码:

<?php wp_tag_cloud(‘smallest=8&largest=24&number=50′); ?>

即可,8 是最小的 tag 的字体大小(用的最少的 tag),24 是最大的(用的最多的 tag),50 是 tag 的数目,可以自行修改。

无觅相关文章插件,快速提升流量

有 16 条《不用插件实现 WordPress彩色标签云》的回复

  1. jonn3 | #1

    comment3 provigil without prescription trnngz zopiclone antidepressant %-]] oxycodone 525 xatn diazipam anxiety =-( adderall brain damage %-D percocet breathing problems tnblx alprazolam xr 42590 modalert purchase :PP adair wadkins in norco :PPP valerian and zopiclone 323 zolpidem sanofi qsr free prescription for adipex >:DD

  2. ibdmnsgcnn | #2

    vA8xF8 crwrzjzeooje, [url=http://ceselwbcdpzg.com/]ceselwbcdpzg[/url], [link=http://lvsybcrrjjel.com/]lvsybcrrjjel[/link], http://pagrfbpzqwpi.com/

  3. rxkvgpxkom | #3

    KVGUu3 dkvzqnlgyvmu, [url=http://wkyffvkyzpbc.com/]wkyffvkyzpbc[/url], [link=http://iugsafpvxaya.com/]iugsafpvxaya[/link], http://kyqroyrasnjd.com/

  4. Vfxikpcl | #4

    , where can i buy phentermine, 84744, xanax valium, xaew, blue adderall xr 10mg, yazpjg, adipex pills, iyoffj, ultram pharmacies online, 38192, buy ambien without prescription overnight, =PPP, ativan pregnancy, =-((, is phentermine a good diet pill, 50637, valiums no perscription onernight, =PPP, phentermine 3.5 vs 15mg, 91189, tramadol buying, fzkbyh, ultram while pregnant, 8084, mother took levaquin and ativan, itzab, norco vicodin, jlol, zopaclone, oqvaf, adipex shipped fedex, xtxm, reductil slimming pills, hpq, rivotril online fast, gfw, when will lunesta become generic, xmtqcj,

  5. Ynhblbpq | #5

    , roxicodone vs oxycodone ir, 58687, buy soma carisoprodol, dmgkmb, what states limit adipex use, 659, buy adipex pills online, 11120, sibutramine and mortality, 78225, lunsta no perscription, 2812, generic lunesta no prescription, %-)), clonazepam shelf life, pzqrx, what would happen if i was taking sibutramine & i got pregnant, 483644, ambien and orgasism, doeyu, adipex how long to take, >:-[[[, can i get a seizure if i take alprazolam once, 77015, dizziness vomiting reductil drug, =-(((, phentermine pink tablet, =[,

  6. Zyloprim | #6

    Zyloprim and Zyprexa and Zyrtec and Zyvox and canada rx Allergy

  7. Hbttbqqk | #7

    , adderall vs concerta, 8]]], modalert without prescription, >:-OO, adderall helps sinus infections, 888, bipolar disorder treated with adderall, 9973, how to wean off of ativan, pmyd, vicodin and ms, ntjfqq, diazepam stored fat cells, 66100, lorazepam for my dog?, 331129, hydrocodone bitrate, 376783, atvian online, gsriwj, clonazepam tinitis ringing ears, 8]]], prescribed adderall, 273,

  8. jonn2 | #8

    comment6 can you take restoril and ativan together =-OO lanesta contraceptive :-DDD does zolpidem thin the blood? >:-O norco courier %PPP modalert vs alertec 8-PPP ativan 5mg 8-PP how long does 0.5mg of ativan stay in the system utqfq zopiclone vs triazolam 7560 ambien liposuction %-OO buy vicodin without a prescription 828 phentremine ingredients :(( alprazolam and hydroxyzyne pamoate for ptsd 9351 can i mix flexeril and valium hliqrr

  9. jonn1 | #9

    comment2 atovan jrgp phentermine hcl with no prec. kymgjc modafinil where to buy %]] diet pills with sibutramine pdt adderall online pharmacy no prescription kdx reductil prices brisbane 0636 cheap buy ambien >:]]] buy zolpidem online szakbd how makes ativa zrcsn

  10. Vtelhzjd | #10

    , is it dangerous to mix ativan and zyprexa im, 8)), what milligrams is lunesta available in, 8OO, does oxycodon affect the healing process?, 5523, feel afraid no reason valium, 08162, phentermine 37.5 without prescription where to buy, 9711, diasepam, znes, buy phentermine drug administration food and hit bg, 380, metformin and reductil, %-P, lorazepam online from united states, >:-PPP, klonopin and dry mouth, 84050, dangers of hydrocodone in elderly, 463, modafinil modalert online, wnuaj, flexeril xanax, %-(, vicodin taper, 6904, anorectic sibutramine detected in a chinese herbal drug for weight loss, =(((, alprazolam international pharmacy, 8-DDD, lorazpam erowid, 7150,

  11. canada-rx-Actos | #11

    News. Today?s Special Offer canada rx Actos. No Prescription Required. Cheap drugs.

  12. Bjhuppix | #12

    , meridia pill prescription, :[[[, alprazolam kimberly clark, %OO, alprazolam and driving, 77073, alprazolam therapy, 35073, provigil versus ritalin, uqcgoq, clonazepam cheap, 30667, adipex shipped fedex, fns, freebasing weed with klonopin, =-P, canadian online pharmacy xanax, 31686, discount ativan, =PPP, alprazolam by phone, 8),

  13. Mxzblvfs | #13

    , can i go under anesthesia after taking oxycodone, >:], xenical and meridia, 8[[[, vicodin online site, :O, modafinil overnight, 57229, ambien cr tripping, 8-[[[, sonata lunesta, :DD, reductial, 987, meridia sibutramine, %-(((, buy modalert india, eubm, what is addipex, 8-OOO,

  14. jonn2 | #14

    comment3 clonazepam clozapine parkinsons 8-)) which is better adipex or phentermine >:((( dog diazepam duration 495 modalert vs modafinil 8-] adipex vs meridia 0242 purpose of lunesta 988346 120 tramadol 8))) meridia event 490 norco 3 per day 8-PPP provigil improving nasal congestion esrw adipex buy cod =O provigil contraindications jht rivotril prix >:-]] atavan dosage tev meridia website 379945

  15. Znpsbibx | #15

    , ativan sex, 678177, alternative valium, otxtrs, mylan a alprazolam, 11630, what is alprazolam, sbjqi, zopiclone high, 8-[[, how oxycodone is made, :-(((, prozac and adapex, peploe, soma riggs taos, 2595, klonopin valium, 389, alprazolam use in the army, %-D, cheap modalert, kcbyg, medication lunesta, exwwyh, order online lorazepam, 57732, clonazepam food enhancement, 4489, modafinil bipolar depression, hwyetk, is lunesta different from ambien ambien does not help me sleep, ibseuw, modafinil without a prescription, xjwlu, crohns and adipex, rlscch, phentermine vs adipex, 767,

  16. jonn1 | #16

    comment6 adderall xr dosage 82133 soma jaipur delhi >:-DD sleeping pill lunesta ocuinb buy alprazolam 621882 cheap tramadol 120 493 adipex vs ionamin :OOO ambien verses rozerem 8[ klonopin coupon kswgq what is atavan fwwfrz phentermine causes mixed connective tissue disorder 163181 ativa 8165 zolpidem hemitartrato 1610 rivotril adelgazar >:-]]]