Posted By

ihatetomatoes on 04/18/11


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

StarkCreations


WP - Add Twitter and Facebook Buttons to Your Posts


 / Published in: PHP
 

URL: http://speckyboy.com/2011/03/28/20-more-wordpress-code-snippets-and-hacks/

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

Report this snippet  

You need to login to post a comment.