Freelance Web Developer, Web Designer Mumbai India Navigation
+91-9820-620-840 [email protected]
  • Home
  • About Me
  • Services
    • Services
    • WordPress Development
    • Website, UI/UX Designing
    • PHP Development
    • E-Commerce Development
    • jQuery Development
    • VueJS Development
    • Graphic Designing
    • SEO Services
  • Portfolio
  • Blog
  • Contact
  • Home
  • About Me
  • Services
    • Services
    • WordPress Development
    • Website, UI/UX Designing
    • PHP Development
    • E-Commerce Development
    • jQuery Development
    • VueJS Development
    • Graphic Designing
    • SEO Services
  • Portfolio
  • Blog
  • Contact

How to display Social sharing links in WooCommerce Single Product Page

In this article I will explain how to display social sharing links in single product page without using any plugin.

This can be done using “woocommerce_share” action. This action is called by WooCommerce in the single product page.

Put the below code in your theme/child-theme functions.php

function theme_prefix_woocommerce_share() {
global $post;

$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail = $thumbnail_id ? urlencode(current(wp_get_attachment_image_src($thumbnail_id, ‘large’))) : ”;
$title = esc_attr($post->post_title);
$permalink = urlencode(get_permalink($post->ID));
?>
<div class=”social”>
<a href=”https://twitter.com/intent/tweet?url=<?php echo $permalink; ?>&text=<?php echo $title; ?>” target=”_blank”>
Twitter
</a>
|
<a href=”https://www.facebook.com/sharer/sharer.php?u=<?php echo $permalink; ?>” target=”_blank”>
Facebook
</a>
|
<a href=”https://plus.google.com/share?url=<?php echo $permalink; ?>” target=”_blank”>
Google+
</a>
|
<a href=”http://pinterest.com/pin/create/button/?url=<?php echo $permalink; ?>&media=<?php echo $thumbnail; ?>&description=<?php echo $title; ?>” target=”_blank”>
Pinterest
</a>
|
<a href=”http://www.linkedin.com/shareArticle?mini=true&url=<?php echo $permalink; ?>&title=<?php echo $title; ?>” target=”_blank”>
LinkedIn
</a>
|
<a href=”http://www.tumblr.com/share?v=3&u=<?php echo $permalink; ?>&t=<?php echo $title; ?>” target=”_blank”>
Tumblr
</a>
</div>
<?php
}

add_action(‘woocommerce_share’, ‘theme_prefix_woocommerce_share’);

Hope this helps.

Share this Post

Social ShareWooCommerce

Categories

  • CSS3
  • HTML5
  • JavaScript
  • jQuery
  • MySql
  • PHP
  • SEO
  • WordPress

Recent Posts

  • Trap Focus Inside an Element January 28, 2020
  • Cross Domain Communication using postMessage December 4, 2018
  • Hot Linking and Protection in HTACCESS November 5, 2018
  • Cron Jobs or Scheduled Events in WordPress June 20, 2018
  • XML-RPC in WordPress March 26, 2018

Popular Tags

.htaccess add_settings_field Ajax File Upload Auto Height Iframe Change Communication Copy Cron Jobs cron_schedules Cross Domain CSS CSS Types Custom Field Domain Embedded CSS External CSS File Upload Focus Focus Event Focus Trap Hosting Hot Linking Hotlink Protection HTML HTML5 http status iframe Inline CSS JavaScript jQuery jQuery File Upload jQuery Trap Focus Loop Focus PHP postMessage Scheduled Events Security seo Social Share Website WooCommerce Word WordPress WordPress Custom Setting wp_schedule_event

Quick Connect

    Stay Connected

    Mumbai, India

    • (+91) 9820 620 840
    • [email protected]
    • taraprasad.swain
    • TaraPrasadSwain
    • taraprasad-swain-93408312
    • swaintara
    • taraswain

    Services

    • WordPress Development
    • Website, UI/UX Designing
    • PHP Development
    • E-Commerce Development
    • jQuery Development
    • VueJS Development
    • Graphic Designing
    • SEO Services

    WhatsApp Me

    © 2025 TARAPRASAD.COM - FREELANCE WEB DESIGNER & DEVELOPER. ALL RIGHTS RESERVED.

    Go to mobile version