and like us on FB

This article will show you how to include your Facebook page likes in plain text with WordPress shortcode, a PHP function, or with our WordPress plugin. This is the first of quite a few articles that’ll show you how to include the counts of various social networks in your websites via various means. This function requires that you register a Facebook application (don’t worry, it’s easy). Follow the steps as described here.

As an example, the count for our Flight Facebook page, using the shortcode of [fblikes id="flightorg"], is 80,838 (bolding is mine). We’ve cached the result for 12 hours and applied number formatting by default (details below). The sad count for BeliefMedia’s page is 37 (we’re yet to promote it in any way).

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

WP Plugin

If you download our plugin you’ll find the menu to update all options under Tools -> BeliefMedia Facebook Counts.

Count Facebook Page Likes with WordPress Shortcode or PHP

Find options at Tools → BeliefMedia Facebook Counts.
As of V0.3, the APP ID is replaced by an access token.

Any attributes supplied in your shortcode will overwrite the options saved to your database (normally just the Facebook page ID).

PHP Function

Used outside of WordPress, the following PHP function may be used. Usage requires Simple Cache (to cache data and avoid repeated and lengthy requests to Facebook).

Arguments are passed to the function in an $args array.

Considerations

  • You might consider rendering the result as an image. There are any number of ways of achieving this – notably with GD or ImageMagick. This very simple example renders each digit as an image.

  • Using our textbox shortcode you can include the count in a nicely formatted manner.

Join 37 others on our very lonely BeliefMedia FB page

or…

Join 37 others on our FB page for regular and free WP Code & Plugins.

  • If you download the plugin we’ll provide you with update notifications via your dashboard. We expect to build lots of features into this plugin, such as the image feature described above.

Download

Title: Count Facebook Page Likes with WordPress Shortcode or PHP
Description: Display a count of FB page likes in plain text with shortcode. Requires the creation of an application.
Download: Shortcode (V0.2) | WP Plugin (V0.2) | PHP Code (V0.2)

Shortt URL for this post: http://shor.tt/1QRm