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!
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch

