WP-PostRatings 只显示评分结果方法

Kevin 杂记 667 次浏览 45条评论

WP-PostRatings 插件使用<?php if(function_exists('the_ratings')) { the_ratings(); } ?>代码添加评分功能,但这是一个完整模块。如果希望只希望显示评分结果,限制点击评分操作,可以使用<?php echo the_ratings_results( get_the_ID() ); ?>获取,多余文本在插件模板选项里删除。

另一个方法是直接从数据库获取评分数据输出,方便修改结构样式。在functions.php主题文件里添加下面代码。

function showRatings($id, $css_class = 'show-ratings') {
 global $wpdb;
 $path = plugins_url('wp-postratings/images/'.get_option('postratings_image'));
 $rating = $wpdb->get_var("SELECT AVG(rating_rating) AS rating FROM $wpdb->ratings WHERE rating_postid = $id");
 $i = 0;
 $html = '<div class="'.$css_class.'">';
 if (!empty($rating)) {
 while ($i < floor($rating)) {
 $html .= '<img src="'.$path.'/rating_on.gif" alt="" />';
 $i++;
 }
 if (round($rating, 1) == ($i+0.5)) {
 $html .= '<img src="'.$path.'/rating_half.gif" alt="" />';
 $i++;
 }
 }
 while ($i < 5) {
 $html .= '<img src="'.$path.'/rating_off.gif" alt="" />';
 $i++;
 }
 $html .= '</div>';
 return $html; 
}

然后使用<?php echo showRatings( get_the_ID() ); ?>代码调用。

评论列表

  1. #1

    hydroxychloroquine sulfate tabs https://hydroxychloroquine.webbfenix.com/

  2. #2

    dose for acyclovir herpes simplex https://www.herpessymptomsinmen.org/productacyclovir/

  3. #3

    ivermectin dosage humans https://ivermectin.webbfenix.com/

  4. #4

    starting dose of naltrexone https://naltrexoneonline.confrancisyalgomas.com/

  5. #5

    hydroxychloroquine clinical trial results https://hydroxychloroquine.mlsmalta.com/

  6. #6

    ivermectin dosing for scabies https://ivermectin.mlsmalta.com/

  7. #7

    keflex sinus infection dosage https://keflex.webbfenix.com/

  8. #8

    vidalista 5mg cost https://vidalista.mlsmalta.com/

  9. #9

    buy zentiva hydroxychloroquine https://hhydroxychloroquine.com/

  10. #10

    tadalafil dapoxetine reviews https://dapoxetine.confrancisyalgomas.com/

  11. #11

    50mg viagra pills http://droga5.net/

  12. #12

    erectile disorder 38 cfr
    buy erection pills
    erectile enhancement pills
    top erectile urologists in san francisco

  13. #13

    vidalista without doctor prescription reviews https://vidalista40mg.mlsmalta.com/

  14. #14

    nolvadex 10mg https://tamoxifen.mrdgeography.com/

  15. #15

    free cialis trial coupon https://wisig.org/

  16. #16

    amstyles.com https://amstyles.com/

  17. #17

    dapoxetine without a doctor prescription not scam https://ddapoxetine.com/

  18. #18

    chloroquine 250 mg tablets https://hydroxychloroquine.grassfed.us/

  19. #19

    chloroquine 250 mg tablets https://hydroxychloroquine.mymvrc.org/

  20. #20

    quineprox 200 mg https://hydroxychloroquinee.com/

  21. #21

    walgreens male enhancement products https://tadalafileo.online/

  22. #22

    walgreens male enhancement products https://tadalafil365.online/

  23. #23

    does erectile dysfunction ever reverse
    erectile dysfunction drugs
    are erectile dysfunction pills dangerous

  24. #24

    erectile aid device
    ed meds
    when does erectile dysfunction happen
    erectile deformity

  25. #25

    vidalista dosage recommendations http://viidalista.co/

  26. #26

    buy erectile dysfunction meds
    erectile injection video

  27. #27

    You have remarked very interesting details! ps nice site. https://local-auto-locksmith.co.uk/kia/

  28. #28

    Świetny post. Bardzo ciekawie opisany artykuł. Jak możesz sprawdź stronę o samochodach u mnie! Do zobaczenia! https://samocholand.pl/

  29. #29

    taking cefixime without ed https://ceefexime.co/

  30. #30

    the best canadian online pharmacies https://edmeds.buszcentrum.com/

  31. #31

    the best canadian online pharmacies https://medpills.bee-rich.com/

  32. #32

    Thanks for your whole work on this website. My niece takes pleasure in working on research and it is simple to grasp why. We all notice all relating to the powerful ways you render vital tips and tricks via your website and therefore welcome response from website visitors on this topic while our own simple princess is without question understanding so much. Take pleasure in the rest of the year. Your performing a very good job. https://lvagroupinc.com/

  33. #33

    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 very helpful 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://bupronbupropion.com/

  34. #34

    A lot of thanks for all your valuable efforts on this site. Kate loves getting into investigation and it’s really easy to understand why. I know all concerning the dynamic medium you give informative solutions on this web blog and as well as foster participation from others on that content plus our daughter is always discovering a lot. Have fun with the remaining portion of the new year. You are conducting a great job. https://venlorz.com/#

  35. #35

    My spouse and i got quite glad that Ervin could deal with his investigations through the ideas he got out of the web page. It’s not at all simplistic to just continually be giving out methods that many other people have been selling. And we also fully understand we have got the website owner to be grateful to for that. The entire explanations you have made, the simple site menu, the friendships you can help foster – it’s got many great, and it’s really helping our son and the family imagine that the issue is entertaining, and that is pretty indispensable. Thank you for everything! https://tofranilimipramine.com/#

  36. #36

    My spouse and i got quite glad that John could deal with his preliminary research through the ideas he grabbed out of your web page. It’s not at all simplistic to just continually be giving out methods that many others have been selling. And we also fully understand we have got the website owner to be grateful to for that. The main explanations you have made, the simple site menu, the friendships you can help foster – it’s got many great, and it’s really helping our son and the family imagine that the matter is excellent, and that is pretty indispensable. Thank you for everything! https://tofranilimipramine.com/#

  37. #37

    buy cialis without seeing doctor http://ciialis.co/

  38. #38

    generic cialis 20 mg price https://cialis.buszcentrum.com/

  39. #39

    generic cialis 20 mg price https://cialis.bee-rich.com/

  40. #40

    generic cialis 60 mg india https://cialis.studiowestinc.com/

  41. #41

    generic cialis 60 mg india https://cialis.adicbc.com/

  42. #42

    Touche. Sound arguments. Keep up the amazing work.

    Feel free to surf to my blog post; bbq chicken grill aluminum foil

  43. #43

    Hello! I realize this is somewhat off-topic however I had to ask.
    Does managing a well-established blog like yours require a large amount of work?
    I’m brand new to operating a blog however
    I do write in my diary on a daily basis. I’d like to start a blog so I will be able to share my
    own experience and feelings online. Please let me know if you have any kind of suggestions or tips for new aspiring
    blog owners. Thankyou!

    My website – grilled chicken steak ala pobre

  44. #44

    Thanks designed for sharing such a pleasant idea, piece of writing is fastidious, thats why i have read it
    completely

    Here is my webpage: pubg jeu

  45. #45

    These are genuinely great ideas in concerning
    blogging. You have touched some good things here.
    Any way keep up wrinting.

    Check out my homepage; pubg telecharger gratuit

发表评论

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