Estimated reading time: 0 minutes, 45 seconds
Yesterday I added the new Tweet button provided by Twitter and the new Like button provided by Facebook to my blog posts (seen above, click them to take the for a test drive). They’re quick and easy ways for readers to share posts with other readers and they even include some nifty little counters too. Oooh fancy!
Combining these buttons with the WordPress codex is pretty easy. Insert a couple snippets of code and you can easily add the URL and post/page title dynamically to the “Tweets” and “Likes”.
The codes from the WordPress codex that we’re going to use are:
<?php the_permalink() ?> and <?php the_title(); ?>
Two lines of code and you’re all set up. Copy and paste the code below, style as needed to position the buttons how you see fit. For the Twitter Tweet button, don’t forget to replace my username with yours.
Facebook Like Button
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php the_permalink() ?>&layout=button_count&show_faces=false&width=100&action=like&font=arial&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
Twitter Tweet Button
<a href="http://twitter.com/share" class="twitter-share-button" data-text="<?php the_title(); ?>" data-count="horizontal" data-via="robbclarke">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
Did you find this useful? Wouldn’t hurt to share it with others would it?