Sharing Buttons Function

The ngfb_get_sharing_buttons() function can include sharing buttons anywhere within your functions and template files. As an example, the following PHP code includes the Facebook, Google+, and Twitter sharing buttons from within a loop, post, or page (the $post->ID must be available):

1

2

3

4

<?phpif(function_exists('ngfb_get_sharing_buttons'))

echongfb_get_sharing_buttons(array('facebook','gplus','twitter'));?>

The sharing button names for the array can be:

buffer

facebook

gplus

linkedin

managewp

pinterest

reddit

stumbleupon

tumblr

twitter

You can also use the ngfb_get_sharing_buttons() function outside of a loop, post, or page, but you will have to provide additional information to the function. Since the $post variable is not available outside of a loop (to get the permalink URL), at a minimum you will have to provide the webpage URL. Here’s an example from a custom NextGEN Gallery template (plugins/nextgen-gallery/view/):