Awesome Way to Add Dynamic Facebook and Tweet Widgets

Almost every blog and website should integrate with Facebook and Twitter if they want to increase traffic to their website and allow people to share their links. Both Twitter and Facebook have widgets that can be placed throughout your WordPress site. In this article you will see how to add Dynamic Facebook and Tweetmeme widgets to your blog post and post listing pages. We will use some WordPress functions as well as good ol’ PHP to get the urls we need to make these buttons dynamic.

Dynamic Facebook and Tweetmeme Widgets

Widgets for Blog Listing Pages

If you have a blog listing page and you want to show the twitter and facebook social share buttons for each listing rather than the blog page itself then the code below will do just that. You will simple need to add the following code into your WordPress loop after either the_content() or the_excerpt() depending on your preference.

For Facebook Share Button:

Notice for the “share_url=” we are using the wordpress permalink function to grab the article’s url.

	
Share

For Tweetmeme



Widgets for Single Posts and Pages (single.php and page.php).

If you want to add the Facebook and Tweetmeme buttons to your single posts then open up your theme’s single.php for posts and page.php for pages and add the following code after your WordPress loop

Facebook Dynamic Like Button for WordPress

Twitter Dynamic ReTweet Button for WordPress

If you want the Tweetmeme retweet button then you can use the following bit of code to display compact retweet buttons. To change the tweetmeme size all you need to do is change the tweetmeme_style to the larger version remove tweetmeme_style = ‘compact’;.

 

Thanks to Rommel Santor and his great blog post for getting me started in the right direction: check out how his detailed article about adding dynamic facebook and tweetmeme widgets to your blog

Leave a Reply

Your email address will not be published. Required fields are marked *