News

How to create facebook and twitter buttons to posts

Many bloggers will be looking out to promote or share their posts in Facebook or twitter.Using plugins will just slow down the site, So i have a code which will create facebook and twitter buttons to posts.

 

 

Step 1 using codes

 

  • Go to the file Functions.php
  • paste the following code and save, Ur 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');




Step 2 using a plugin


We can also add facebook and twitter or other social media icons through a plugin

Install the plugin below for wordpress, and ur done.

Click here for download this plugin.

 


Versi cetak

Related Keywords

and, create, facebook, how, posts, to, twitter buttons

Direkomendasikan


Tentang KLATENWEB

Jasa pembuatan aplikasi web berbasis PHP dan MySQL, Web Portal, Personal, Toko Online, Sistem Informasi Akademik, SIMPeg dan Rumah Sakit, Aplikasi Facebook, dan lain sebagainya termasuk penyedia domain dan hosting unlimited murah.