Add Twitter and Facebook buttons to your blog posts

  • Posted on: 2 November 2011
  • By: Pradeep George

There are several ways you can add the Twitter and Facebook buttons to your blog posts so that people can easily share your artciles or blog posts. One of the easiest way to add the following php code in to your page.

1. In Drupal, make sure you have enabled "PHP filter" in your module section.
2. Create a new block for Twitter and Facebook section
3. Add the below php code in the body as "Source" in case you have wysiwyg editor enabled
4. Select the Text format as "PHP code"
5. Save and add the block in your blog section.

Have a great time blogging!

<div class="share-this"> <a href="" class="twitter-share-button" data-count="horizontal">Tweet</a> <script type="text/javascript" src=""></script> <div class="facebook-share-button"> <iframe src="'. urlencode(get_permalink($post->ID)) .'&amp;layout=button_count&amp;show_faces=false&amp;width=200&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:21px;" allowTransparency="true"></iframe> </div> </div>


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.