Home / Tricks / How To Automatically add Twitter and Facebook buttons to your posts How To Automatically add Twitter and Faceboo


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function share_please($content){
  2. if(!is_feed() && !is_home()) {
  3. $content .= '<div class="share-this">
  4. <a href="<a href="http://twitter.com/share&quot" rel="nofollow">http://twitter.com/share&quot</a>;
  5. class="twitter-share-button"
  6. data-count="horizontal">Tweet</a>
  7. <script type="text/javascript"
  8. src="<a href="http://platform.twitter.com/widgets.js%22%3E%3C/script&gt" rel="nofollow">http://platform.twitter.com/widgets.js"></script&gt</a>;
  9. <div class="facebook-share-button">
  10. <iframe
  11. src="<a href="http://www.facebook.com/" rel="nofollow">http://www.facebook.com/</a><a title="plugins" href="http://wptricks.net/category/plugins/">plugins</a>/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_please');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.