How to Add Social Sharing Buttons to the WooCommerce Single Product Page Without a Plugin – 2026

Last updated on August 25th, 2024 at 05:42 pm

Adding social sharing buttons to your WooCommerce single product page can significantly increase your store’s visibility and drive more traffic. While there are many plugins available for this purpose, adding social sharing buttons without a plugin ensures better performance and reduces the risk of conflicts with other plugins. This guide will walk you through adding social sharing buttons for popular social media platforms like Twitter, Facebook, Instagram, and others directly to your WooCommerce product pages using custom code.

Why Add Social Sharing Buttons?

Social sharing buttons on your product pages allow customers to share their favourite products with their social networks, which can:

  • Increase product visibility and reach.
  • Drive more traffic to your store.
  • Boost sales through social proof.

Step 1: Backup Your Site

Before making any changes, ensure you have a complete backup of your website. This step is crucial to prevent data loss in case something goes wrong.

Step 2: Access Your Theme’s Functions File

To add custom code, you need to edit your theme’s functions.php file. If you don’t have a child theme, you can use our free child theme generator.

Step 3: Upload Social Icons

Find social media icons to use for your buttons. You can use a website such as Icon Finder, Flaticon or Freepic. Once you have your icons you can upload them to your media library. You can also use font icons such as Dashicons, which are built into WordPress, or Fontawesome instead of images.

Step 4: Add Social Sharing Buttons Code

Add the following code to your theme’s functions.php file to create social sharing buttons:

/*
 * Snippet: How to Add Social Sharing Buttons to the WooCommerce Single Product Page Without a Plugin – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1383
* Tested with WooCommerce 10.7.0
* "Add social sharing buttons to WooCommerce single product page"
*/ function wcsuccess_social_sharing_buttons() { global $product; $product_url = get_permalink($product->get_id()); $product_title = get_the_title($product->get_id()); ?> <div class="social-sharing-buttons"> <a href="https://twitter.com/share?url=<?php echo urlencode($product_url); ?>&text=<?php echo urlencode($product_title); ?>" target="_blank" rel="noopener noreferrer"> <img src="path/to/twitter-icon.png" alt="Share on Twitter"> </a> <a href="https://www.facebook.com/sharer.php?u=<?php echo urlencode($product_url); ?>" target="_blank" rel="noopener noreferrer"> <img src="path/to/facebook-icon.png" alt="Share on Facebook"> </a> <!-- Add more social media buttons as needed --> </div> <?php } add_action('woocommerce_single_product_summary', 'wcsuccess_social_sharing_buttons', 35);

Adding Instagram and Other Social Networks

While Instagram doesn’t support direct sharing via URL parameters, you can encourage users to share the product manually. You can also add buttons for other networks like LinkedIn and Pinterest:

/*
 * Snippet: How to Add Social Sharing Buttons to the WooCommerce Single Product Page Without a Plugin – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1383
* Tested with WooCommerce 10.7.0
* "Add social sharing buttons to WooCommerce single product page"
*/ function wcsuccess_social_sharing_buttons() { global $product; $product_url = get_permalink($product->get_id()); $product_title = get_the_title($product->get_id()); ?> <div class="social-sharing-buttons"> <a href="https://twitter.com/share?url=<?php echo urlencode($product_url); ?>&text=<?php echo urlencode($product_title); ?>" target="_blank" rel="noopener noreferrer"> <img src="path/to/twitter-icon.png" alt="Share on Twitter"> </a> <a href="https://www.facebook.com/sharer.php?u=<?php echo urlencode($product_url); ?>" target="_blank" rel="noopener noreferrer"> <img src="path/to/facebook-icon.png" alt="Share on Facebook"> </a> <a href="https://www.linkedin.com/sharing/share-offsite/?url=<?php echo urlencode($product_url); ?>" target="_blank" rel="noopener noreferrer"> <img src="path/to/linkedin-icon.png" alt="Share on LinkedIn"> </a> <a href="https://pinterest.com/pin/create/button/?url=<?php echo urlencode($product_url); ?>&media=<?php echo urlencode(wp_get_attachment_url(get_post_thumbnail_id($product->get_id()))); ?>&description=<?php echo urlencode($product_title); ?>" target="_blank" rel="noopener noreferrer"> <img src="path/to/pinterest-icon.png" alt="Share on Pinterest"> </a> <a href="https://www.instagram.com" target="_blank" rel="noopener noreferrer"> <img src="path/to/instagram-icon.png" alt="Share on Instagram"> </a> </div> <?php } add_action('woocommerce_single_product_summary', 'wcsuccess_social_sharing_buttons', 35);

Step 5: Styling the Social Sharing Buttons

To style your social sharing buttons, add the following CSS to your theme’s stylesheet (style.css):

/*
 * Snippet: How to Add Social Sharing Buttons to the WooCommerce Single Product Page Without a Plugin – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1383
* Tested with WooCommerce 10.7.0
* "Style
*/ .social-sharing-buttons { margin-top: 20px; } .social-sharing-buttons a { display: inline-block; margin-right: 10px; } .social-sharing-buttons img { width: 24px; height: 24px; }

Conclusion

Adding social sharing buttons to your WooCommerce single product page without a plugin can enhance your store’s visibility and drive more traffic. By integrating these buttons directly into your theme, you can maintain a fast, conflict-free website. Remember to back up your site before making any changes and consider using our free child theme generator if you don’t have a child theme. Happy selling!

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×