Sharing Buttons Function

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

The sharing button names for the array can be:

  • email
  • facebook
  • linkedin
  • pinterest
  • pocket
  • reddit
  • tumblr
  • twitter
  • 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, and uses the picture's caption as well.