Wednesday, February 28, 2024

WordPress Reference
< All Topics

X | The Theme: How to add social sharing buttons after the post content

Adding the following code to the x-theme child theme’s function.php file worked for me.

// Add Social Sharing after the single post content
// =============================================================================

function x_add_social_sharing ( $content ) {
  if ( is_singular('post') ) {
    echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
add_action('x_before_the_content_end', 'x_add_social_sharing');

The code above is a variation of a solution I obtained from an old forum, and, though it worked for me, the forum notice says that it is no longer supported.  The variation I made was to remove Google+ from the shares. A link to the forum  post follows:

Table of Contents