在日志底部自动添加Twitter和Facebook按钮

WordPress24.7K阅读模式

把下面的代码粘贴到您的 functions.php 模板文件中,保存,大功告成了。虽然Twitter已被GFW,记录一下添加方法也不错。

  1. function share_this($content){
  2. if(!is_feed() && !is_home()) {
  3. $content .= '<div class="share-this">
  4. <a href="http://twitter.com/share"
  5. class="twitter-share-button"
  6. data-count="horizontal">Tweet</a>
  7. <script type="text/javascript"
  8. src="http://platform.twitter.com/widgets.js"></script>
  9. <div class="facebook-share-button">
  10. <iframe
  11. src="http://www.facebook.com/plugins/like.php?href='.
  12. urlencode(get_permalink($post->ID))
  13. .'&amp;layout=button_count&amp;show_faces=false&amp;width=200&amp;action=like&amp;colorscheme=light&amp;height=21"
  14. scrolling="no" frameborder="0" style="border:none;
  15. overflow:hidden; width:200px; height:21px;"
  16. allowTransparency="true"></iframe>
  17. </div>
  18. </div>';
  19. }
  20. return $content;
  21. }
  22. add_action('the_content', 'share_this');

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
评论  2  访客  2
    • someby
      someby 1

      具体是黏贴到哪个位置呢 大侠

      • mppt
        mppt 0

        试了下没成功

      匿名

      发表评论

      匿名网友
      :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

      拖动滑块以完成验证