• Resolved Basit

    (@basitbasit11333)


    Hi,

    can you share a code to make affiliate links on all of my post “no follow” and “sponsored”

    like code to add functionality to my whole site that whenever I use a affliate link it automatically becomes no follow, sponsored

    Kindly also share steps to do so

    I don’t want to use plugins

    cms is wordpress, theme is GP

    I am specifically making it to ensure google instructions here is the link

    https://developers.google.com/search/blog/2021/07/link-tagging-and-link-spam-update

    thanks
    ,

    regrad,

    Basit

    • This topic was modified 3 years, 7 months ago by Basit.
    • This topic was modified 3 years, 7 months ago by Basit.
    • This topic was modified 3 years, 7 months ago by Basit.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there,

    how would we identify a link is an Affiliate link ?

    If All external links are Affiliate Links then its a WP core function, and there are several code snippets on the web providing this eg.

    https://crunchify.com/how-to-add-relsponsored-or-relnofollow-to-all-external-links-in-wordpress/

    • This reply was modified 3 years, 7 months ago by David.
    Thread Starter Basit

    (@basitbasit11333)

    Sorry

    I missed mentioning one thing

    I want to make any affiliate external link from my website going to amazon {no follow sponsored}

    will this be useful and let me know where I can place it o automate my external links going to amazon?

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
    </script><script type="text/javascript"> $(document).ready(function() {
    $("a").each(function(){ if($(this).attr("href").indexOf("amazon") != -1 ||
    $(this).attr("href").indexOf("amzn") != -1) { $(this).attr("rel","sponsored noopener");
    $(this).attr("href", $(this).attr("href") + "?tag=amazon-ID"); } }); }); </script>

    IN this code I will replace my amazon ID

    Is there any way of adding this to my site without using plugin

    • This reply was modified 3 years, 7 months ago by Basit.
    • This reply was modified 3 years, 7 months ago by Basit.

    Found this article related to amazon links:

    https://michaelkummer.com/tech/wordpress-link-attributes/

    But this is not Theme related, as GP has nothing to do with how links are generated, thats a core WP function. So the above is about as much help as i can offer.

    Thread Starter Basit

    (@basitbasit11333)

    This was all I needed thanks David

    Thread Starter Basit

    (@basitbasit11333)

    End of discussion

    Glad to hear that!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘change affiliate links to no follow sponsored’ is closed to new replies.