Shortcode: Facebook Like Button

Add following code where you want to display it.


[fb_like layout='button_count']

Add following snippet to “functions.php”


add_shortcode('fb_like', 'wpds_fb_like');
function wpds_fb_like( $atts, $content=null ){
    /* Author: Nicholas P. Iler
    * URL:
    'send' => 'false',
    'layout' => 'standard',
    'show_faces' => 'true',
    'width' => '400px',
    'action' => 'like',
    'font' => ”,
    'colorscheme' => 'light',
    'ref' => ”,
    'locale' => 'en_US',
    'appId' => ” // Put your AppId here is you have one
    ), $atts));
    $fb_like_code = '<div id="fb-root"></div>
    <script src="$locale/all.js#appId=$appId&amp;xfbml=1"></script>
    <fb:like ref="$ref" href="$content" layout="$layout" colorscheme="$colorscheme" action="$action" send="$send" width="$width" show_faces="$show_faces" font="$font"></fb:like>';
    return $fb_like_code;

Courtesy: Nicholas P. Iler

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>