Facebook Page Like Count WordPress Shortcode

The easiest way to show your facebook page like count is to use the facebook like button. As it comes with a limited module and not show only the number count rather than adding a like or recommend text, somewhere it becomes useless. However they have API to server you the count in number, if you have proper code.

add_shortcode('fb_likes', 'w4dev_fb_like_count_shortcode' );
function w4dev_fb_like_count_shortcode( $atts )
{
	extract( shortcode_atts( array(
		'page' => 'w4dev'
	), $atts ));
	$count = facebook_like_count( $page );
	return $count;
}
function w4dev_fb_like_count( $page = 'w4dev' ){
	$url = 'http://graph.facebook.com/'. urlencode( $page );
	$content = wp_remote_retrieve_body( wp_remote_request( $url));
	if( is_wp_error( $content))
		return 0;

	$content = json_decode( $content);
	$value = intval( $content->likes);

	return $value;
}

You can use shortcode [fb_likes page="mypage"], or can use function w4dev_fb_like_count("mypage") to get your Facebook page likes. mypage could be either you facebook page name or page id.