large shade tree

Navigation

Information

Recent Posts

Shade Tree Sites |Building Better Websites

How to Add Facebook and Twitter Buttons Without a Plugin

Facebook Like Button:

Add following to page, post, template where you want it to appear:

<iframe src=”http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=false&amp;
width=450&amp;action=like&amp;colorscheme=light” scrolling=”no” frameborder=”0″ allowTransparency=”true” style=”border:none; overflow:hidden; width:450px; height:60px;”>
</iframe>

Options:

  • Show the friend icons under the button:  show_face=true
  • Display the simple button and the count only:  layout=button_count
  • Darker color scheme for your button:  colorscheme=dark
  • Change the text from Like to Recommendaction=recommend
  • You can also change the width and height of the iFrame as needed

Official Twitter Button:

Add following to template within the wordpress loop (meaning after php if (have_posts()) : while (have_posts()) : the_post();) :

Adds Button with:

  • share URL is the page URL
  • Tweet Text is the page title
  • via @your twitter name
  • in english

<a href=”https://twitter.com/share” data-via=”your twitter name” data-count=”none”>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=”//platform.twitter.com/widgets.js”;fjs.parentNode.insertBefore(js,fjs);}}(document,”script”,”twitter-wjs”);</script>

Adds Button with:

  • share URL is the page URL
  • Tweet Text is the page title
  • via @your twitter name
  • in english
  • shows count

<a href=”https://twitter.com/share” data-via=”your twitter name”>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=”//platform.twitter.com/widgets.js”;fjs.parentNode.insertBefore(js,fjs);}}(document,”script”,”twitter-wjs”);</script>