Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #291001

    5starmoto
    Participant

    Hi,

    Please could you tell me how to add social share buttons (facebook, twitter) to every product?

    thanks
    5starmoto

    #291548

    Nico
    Moderator

    Hi There,

    Thanks for writing.

    You could try adding this code in your customizer’s Custom JavaScript:

    jQuery( document ).ready(function() {
    jQuery( “.x-entry-share” ).insertBefore( “.single-product .product_meta” );
    });

    .single-product .product_meta <- class to be inserted. You can change it wherever you want.

    Hope it helps.

    Thanks.

    #292468

    5starmoto
    Participant

    thank you for the reply.

    I have tried this but its not working? i might not be inserting facebook and twitter correctly, please could you show me the correct way?

    thanks
    5starmoto

    #293052

    Friech
    Moderator

    Hi There,

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices. Then add this to your child theme’s functions.php file

    /*adding social sharing buttons to woocommerce product pages */
    
    add_action("woocommerce_single_product_summary", "add_social_sharing_to_product_page", 60);
    
    function add_social_sharing_to_product_page() {
      echo do_shortcode("[share title='Share this Product' facebook='true' twitter='true' google_plus='true' pinterest='true' email='true' class='mtl']");
    }

    Hope it helps, Cheers!

    #652432

    2342J
    Participant

    Hi,
    I tried adding this code to my funcitons.php file. It works but does not show the interior of the share button (no “f” for facebook, etc.)

    Do you know how I would add that, or a better snippet of code to use for this functionality?

    Thanks!

    #652468

    2342J
    Participant
    This reply has been marked as private.
    #652578

    Jade
    Moderator

    Hi Landon,

    I have checked on your page but I am getting the error:

    Parse error: syntax error, unexpected T_STRING in /.../.../www/www/wp-content/themes/x-child/functions.php on line 42

    Kindly fix it first so that we can check on this further. Thank you.

    #652771

    2342J
    Participant

    Sorry for the inconvenience, I had a bit of a booboo today. It’s fixed. Can you take another look at it?

    #652963

    John Ezra
    Member

    Hi there,

    Thanks for updating the thread! Upon checking your site, we see that you still have X-Shortcodes activated. Please deactivate and delete X-Shortcodes. Then install Cornerstone even if you don’t intend to use our new page builder. Cornerstone retires and replaces X-Shortcodes. The shortcodes required for X to funciton properly are within Cornerstone, hence it is a required plugin. Having both installed (even while deactivated) will cause conflicts.

    Hope this helps – thanks!