Sharing Buttons Function

The wpssorrssb_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):

The sharing button names for the array can be:

  • email
  • facebook
  • twitter
  • pinterest
  • linkedin
  • reddit
  • pocket
  • tumblr
  • vk
  • whatsapp

You can also use the wpssorrssb_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/):

This creates a Pinterest and Tumblr button to share a picture from a NextGEN Gallery, sets the URL to the current webpage address, and uses the picture’s caption as well.