Add Twitter and Facebook buttons to wordpress posts

wordpress tutorial, how to Add Twitter and Facebook buttons to wordpress posts.  we need to install the various plugins without installing any wp plugin.

Add Twitter and Facebook buttons to wordpress posts

For showing the facebook and twitter button in wordpress post many times we need to install the various plugins but with following code you dont need to install the wordpress plugin.

Add Twitter and Facebook buttons to wordpress posts
Add Twitter and Facebook buttons to wordpress posts

If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file.

function facebook_twitter_button($content){
    if(!is_feed() && !is_home()) {
        $content .= '<div class="facebook-twitter-button">
                    <a href="http://twitter.com/share"
class="twitter-share-button"
data-count="horizontal">Tweet</a>
                    
src="http://platform.twitter.com/widgets.js">
                    <div class="facebook-share-button">
                        <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', 'facebook_twitter_button');

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.