Home Forums WoodMart support forum Adding rel=”sponsored” Attribute to Add To Cart button link on WooCommerce

Adding rel=”sponsored” Attribute to Add To Cart button link on WooCommerce

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #431076

    webtech
    Participant

    Hi, what’s the best way to add rel=”sponsored” attribute on the Add To Cart button of this theme? We are using your theme for affiliate products. In our case, we changed the Add to Cart button text to Buy on Amazon for External/Affiliate products on WooCommerce.

    I tried Rank Math to handle these links automatically, to no avail.

    Thanks.

    Attachments:
    You must be logged in to view attached files.
    #431157

    webtech
    Participant

    Hi, any update on this?

    #431196

    webtech
    Participant

    I have tried adding the following code to no avail. Can you please check? Thanks.

    add_filter('woocommerce_loop_add_to_cart_link', 'add_rel_attribute_to_external_products', 10, 2); 
     
    function add_rel_attribute_to_external_products($link, $product) { 
       if ($product->is_type('external')) { 
          $link = str_replace('<a ', '<a rel="sponsored" ', $link); 
       } 
       return $link; 
    } 

    Do we need to do this differently on your theme template? If so, which file and what code do we add? Please guide accordingly.

    Thank you.

    • This reply was modified 1 year, 11 months ago by webtech.
    #431207

    webtech
    Participant

    To Woodmart support. You have been actively responding to other concerns on this forum but not on ours. Why is that?

    #431241

    webtech
    Participant

    Wow… support is really bad here. This will reflect in our review of the theme definitely.

    #431262

    webtech
    Participant
    add_filter('woocommerce_loop_add_to_cart_link', 'add_rel_attribute_to_external_products', 10, 2); 
     
    function add_rel_attribute_to_external_products($link, $product) { 
       if ($product->is_type('external')) { 
          $link = str_replace('<form ', '<form rel="sponsored" ', $link); 
       } 
       return $link; 
    }

    The above code doesn’t do it as well. Need your advice here.

    #431284

    Artem Temos
    Keymaster

    Hello,

    We are terribly sorry for the delay.

    Could you please clarify what this code is supposed to do? Have you tested it with a default WordPress theme? If so, please, send us a link to your website where we can see how it works. Then we will do our best to help you to make it work with WoodMart either.

    Kind Regards

    #431323

    webtech
    Participant

    Hi Artem,

    We are only trying to add rel=”sponsored” attribute to the Add To Cart button for External/Affiliate products. See the screenshot after adding the code.

    Our online store has a mix of our own products and affiliate products. We’d like to add sponsored attributes to external products to avoid being penalized by Google.

    Our site link is store.greencitizen.com

    • This reply was modified 1 year, 11 months ago by webtech.
    Attachments:
    You must be logged in to view attached files.
    #431334

    Artem Temos
    Keymaster

    Hello,

    Yes, we understand the purpose but this form is not a part of our theme. It is a WooCommerce plugin functionality which is why we don’t have either option or a custom code snippet for this.

    Kind Regards

Viewing 9 posts - 1 through 9 (of 9 total)