WordPress 使用标签作为文章缩略图

Kevin 杂记 1,473 次浏览 52条评论

对于文章内容关联度比较高的站点,使用标签作为文章缩略图是个不错选择,这样不必每篇文章都设置特色图片。WordPress 标签选项不支持设置缩略图,但可以借助 get_the_tags() 函数实现。

功能效果:获取文章第一个标签的别名数据作为缩略图文件名称,然后在 img 标签内调用,里面设置好图片路径。如果文章没有标签,就显示一个默认标签图片。


$posttags = get_the_tags();
$count = 0;
if ($posttags) {
 foreach ($posttags as $tag) {
 if (1 == $count) {
 echo '<img src="' . get_bloginfo('url') . '/wp-content/uploads/' . $tag->slug . '.jpg" alt="' . $tag->name . '" />';
} else {
 echo '<img src="' . get_bloginfo('url') . '/wp-content/uploads/no-tag.jpg" alt="No Tag" />';


如果觉得手动设置文件名麻烦,有些插件可以扩展 WordPress 标签选项,使其可以设置缩略图,再调用插件的相关函数,例如 DFOXT Thumbnails。


  1. #1

    naltrexone for autoimmune diseases reviews https://naltrexoneonline.confrancisyalgomas.com/

  2. #2

    ivermectin side effects blood pressure https://ivermectin.mlsmalta.com/

  3. #3

    cvs pharmacy coupons for careprost https://carepro1st.com/

  4. #4

    dapoxetine medicine price in india https://salemeds24.wixsite.com/dapoxetine

  5. #5

    ivermectin walmart https://ivermectin.webbfenix.com/

  6. #6

    comparison levitra clomiphene https://salemeds24.wixsite.com/clomid

  7. #7

    hydroxychloroquine to prevent covid https://hydroxychloroquine.webbfenix.com/

  8. #8

    is 150 mg sildenafil safe http://droga5.net/

  9. #9

    online pharmacy cialis http://www.lm360.us/

  10. #10

    vidalista generic cost per pill https://vidalista.mlsmalta.com/

  11. #11

    hydroxychloroquine sulfate 300 mg https://hydroxychloroquine.mlsmalta.com/

  12. #12

    generic vidalista price https://vidalista40mg.mlsmalta.com/

  13. #13

    nolvadex during steroid cycle https://tamoxifen.mrdgeography.com/

  14. #14

    what is cialis professional https://wisig.org/

  15. #15

    tapering off plaquenil https://hydroxychloroquinee.com/

  16. #16

    amstyles.com https://amstyles.com/

  17. #17

    viagra dapoxetine levitra comparison chart https://ddapoxetine.com/

  18. #18

    hydroxychloroquine 200mg side effects https://hydroxychloroquine.grassfed.us/

  19. #19

    hydroxychloroquine 200mg side effects https://hydroxychloroquine.lm360.us/

  20. #20

    cialis tadalafil 20mg price https://tadalafil.cleckleyfloors.com/

  21. #21

    get a prescription https://buymeds.mlsmalta.com/

  22. #22

    cialis side effects dangers https://cialzi.com/

  23. #23

    how vidalista works http://viidalista.co/

  24. #24

    dangerous side effects of prednisone https://bvsinfotech.com/

  25. #25

    I like this blog very much, Its a rattling nice post to read and incur information. I really love your website! https://local-auto-locksmith.co.uk/hyundai/

  26. #26

    Wohh just what I was searching for, appreciate it for posting. https://local-auto-locksmith.co.uk/kia/

  27. #27

    Si está buscando un buen préstamo personal o un préstamo rápido, consulte esta página. http://prestamospersonaleswsrz.es/

  28. #28

    Thanks for your own work on this website. My mother take interest in setting aside time for research and it is simple to grasp why. My spouse and i notice all relating to the powerful way you provide valuable tips via your website and in addition recommend response from visitors on this subject matter while our own simple princess is undoubtedly studying so much. Take pleasure in the rest of the year. You have been performing a tremendous job. https://harrington-service.com/

  29. #29

    I enjoy you because of all your efforts on this site. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all concerning the compelling means you deliver good information by means of the blog and as well cause contribution from other people about this concept plus my daughter is actually being taught a lot. Enjoy the remaining portion of the new year. You’re the one carrying out a first class job. https://harrington-service.com/

  30. #30

    I precisely had to appreciate you all over again. I’m not certain the things I might have done in the absence of the actual ideas discussed by you concerning such field. It actually was a real difficult condition for me personally, but discovering a new professional form you handled it forced me to jump for delight. I’m just happier for the guidance and as well , have high hopes you comprehend what a powerful job you’re carrying out instructing most people through your blog. I am sure you’ve never encountered all of us. https://abilifyaripiprazoles.com/

  31. #31

    I precisely needed to appreciate you once again. I am not sure the things that I might have handled in the absence of the entire pointers provided by you on such a problem. It has been a very frightening difficulty in my circumstances, however , looking at the skilled manner you processed that made me to jump over fulfillment. I am happier for this help and in addition hope that you know what a great job you are always getting into instructing others through the use of your site. I know that you have never encountered all of us. https://desyreltrazodone.com/

  32. #32

    viagra cream price https://viaplz.com/

  33. #33

    tadalafil india generic https://cialis.grassfed.us/

  34. #34

    tadalafil india generic https://cialis.buszcentrum.com/

  35. #35

    generic tadalafil without subscription https://tadfil.online/

  36. #36

    Great information. With thanks. https://www.goldkamagra.com kamagra 100 mg jelly yan etkileri Ehaceuz

  37. #37

    cialis 5 mg online pharmacy http://cialis.anafassia.com/

  38. #38

    australian shepherd stromectol toxicity https://ivermectin1st.com/

  39. #39

    price of cialis 5 mg https://cialis.stdstory.com/

  40. #40

    price of cialis 5 mg https://cialis.lm360.us/

  41. #41

    buy zentiva hydroxychloroquine https://hhydroxychloroquine.com/

  42. #42

    buy hydroxychloroquine online https://hydroxychloroquinex.com/

  43. #43

    Bardzo interesujący temat, dziękuję za wysłanie wiadomości chusteczki. https://chusteczkin.pl/

  44. #44

    cost of viagra

  45. #45

    canadian online pharmacy no prescription

  46. #46

    online canadian pharmacy

  47. #47

    canadian pharmacies online

  48. #48

    top rated canadian online pharmacy

  49. #49

    list of legitimate canadian pharmacies

  50. #50

    canadian pharmacies mail order

  51. #51

    tadalafil 10mg online https://cialis.confrancisyalgomas.com/

  52. #52

    tadalafil 10mg online https://cialis.adicbc.com/


电邮地址用于 Gravatar 头像显示,不会被公开可见。