How To Add Facebook and Twitter Button Into WordPress Post

March 5th, 2011 by oecilkritingz | Posted under Tips n Trik, Wordpress.

Adding Facebook and Twitter Button Into WordPress Post

add facebook buttonThese days, most bloggers are using Facebook and Twitter to promote their posts. In today’s recipe, I’m going to show you how you are able to easily add Twitter and Facebook buttons to the bottom of your posts.

Thanks to Dev7Studios for this awesome recipe!

Paste the code below into your functions.php file, save it, and you’re done.

 

function share_this($content){
    if(!is_feed() && !is_home()) {
        $content .= '<div>
                    <a href="http://twitter.com/share"
class="twitter-share-button"
data-count="horizontal">Tweet</a>
                    <script type="text/javascript"
src="http://platform.twitter.com/widgets.js"></script>
                    <div>
                        <iframe
src="http://www.facebook.com/plugins/like.php?href='.
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>';
    }
    return $content;
}
add_action('the_content', 'share_this');

 

Source:

Automatically add Twitter and Facebook buttons to your posts

http://www.wprecipes.com/automatically-add-twitter-and-facebook-buttons-to-your-posts

 

Related Posts Plugin for WordPress, Blogger...

Tags: , , ,

Comments are closed.