My Affiliate Link WordPress Plugin

[ftcdisclosure]

Last Updated: July 21, 2020
Current Version: 1.0.7

Documentation is currently incomplete. More documentation to follow.

What Is It?

My Affiliate Link is a simple WordPress plugin that allows you to create affiliate links in a standardized way. You insert your affiliate links via shortcodes. It expands to correct and valid HTML with preformed information.

My Affiliate Link is NOT a link management system. It works with your existing tool to better format your affiliate links.

No need to worry about if you forgot to add rel=”nofollow” to a link, or forgot to open your affiliate link in a new tab. Should you change affiliate systems, this WordPress plugin allows you to switch with ease.

This plugin is used on this very site to format and manage affiliate links.

This plugin can work with any affiliate management system that supports link cloaking. It will work with link cloaking services such as:

Though I personally use and recommend ClickMeter. See my review of ClickMeter for more details.

There’s also an Amazon Associates shortcode so you can format your Amazon links to adhere to Amazon’s legal terms.

Why Use It?

  • A standardized way to format all affiliate links.
  • Makes sure you rel=”nofollow sponsored” for all affiliate links (which is required by Google and correct SEO).
  • Is affiliate management agnostic. If say you are currently using Pretty Links, but want to change to ClickMeter, this makes the transfer easy.
  • Newer versions of WordPress (version 5.1 and greater to be exact) automatically add rel=”noreferral” to all external links. Some affiliate programs require HTTP referral which this will block. This plugin makes sure ‘noreferral’ isn’t added to your affiliate links.
  • By default opens affiliate links in a new browser tab (target=”_blank”) which is my recommended way to open external links.

How To Use?

  1. Install and activate the WordPress plugin on your website. This can be done with the “Plugins” section by selecting “Add New”. Then search for “My Affiliate Link”.
  2. Install a link cloaking plugin such as Thirsty Affiliates.
  3. Configure My Affiliate Link settings to match up to the link cloaking plugin you are using (see screenshot below for an example).
  4. Use the shortcodes listed below.

Plugin Rules

  • Merchant links should be all lowercase with no spaces and should match the trailing link within your link shorting service.
  • Merchant links are NOT validated with your link shorting service, so it’s possible to create bad links.
  • Ideally, the child tag should be unique throughout your website and not reused.
  • Not every affiliate system supports the child tag.
  • If you want to disable the redirection page from displaying use child=”nr” as the option.

Shortcode Syntax

Affiliate Links

Use this shortcode when you want to add an affiliate link within the text of a WordPress post or page.

There are two variations of the shortcode. One with when you use the text parameter to pass the text link, and the other you encapsulate the text.

[mal_link merchant="MERCHANT" ( child="CHILD" | title="TITLE" | class="CSSCLASS" | style="CSS>" | encode="true|false")]LINK TEXT[/mal_affiliate_link]
[mal_link merchant="MERCHANT" text="LINK TEXT" ( child="CHILD" | title="TITLE" | class="CSSCLASS"
| style="CSS"| encode="true|false") /]

If using the second option, make sure you end your shortcode with the /. Otherwise, WordPress can get confused when one shortcode ends and a new one begins.

Parameters

  • merchant (required) – The merchant slug. Cannot contain any spaces, dashes, or underscores.
  • link text (required) – The link text.
  • child – A unique identifier for the merchant link. Not supported by all affiliate systems.
  • title – The HTML ‘title’ tag.
  • encode – Defaults to ‘true’ and will encode the output using ‘esc_attr’ function.
  • class – The HTML ‘class’ tag to insert a CSS class.
  • style – The HTML ‘style’ tag to insert direct CSS code.

Affiliate Buttons

This shortcode is to help differentiate text links from buttons used on the site.

[mal_button merchant="MERCHANT" text="LINK TEXT" ( child="CHILD" | title="TITLE" | class="CSSCLASS" | style="CSS") /]

Parameters

  • merchant (required) – The merchant slug. Cannot contain any spaces, dashes, or underscores.
  • text (required) – The link text.
  • child – A unique identifier for the merchant link. Not supported by all affiliate systems.
  • title – The HTML ‘title’ tag.
  • encode – Defaults to ‘true’ and will encode the output using ‘esc_attr’ function.
  • class – The HTML ‘class’ tag to insert a CSS class.
  • style – The HTML ‘style’ tag to insert direct CSS code.

Amazon link (two variations)

[mal_amazon asin="AMAZONASIN" (tid="TRACKINGID" | title="TITLE" | class="CSSCLASS" | style="CSS")]LINK TEXT[/affiliate_link]
[mal_amazon asin="AMAZONASIN" text="LINK TEXT" (tid="TRACKINGID" | title="TITLE" | class="CSSCLASS" | style="CSS") /]

Parameters

  • asin (required) – The amazon product id.
  • text (required) – The link text.
  • tid – Overrides the default Amazon Tracking ID setup within the plugin.
  • title – The HTML ‘title’ tag.
  • class – The HTML ‘class’ tag to insert a CSS class.
  • style – The HTML ‘style’ tag to insert direct CSS code.

Examples

A link to Bluehost merchant with the link text “bluehost” and CSS class “reviewlink”.

[mal_link merchant="bluehost" child="mal" class="reviewlink" text="Bluehost" /]

Which will expand into this HTML.

<a href=“https://larryludwig.com/go/bluehost/mal” target=“_blank” rel=“nofollow sponsored noopener” class=“reviewlink mal-bluehost-review1">Bluehost</a>

And will look like this.

[mal_link merchant="bluehost" child="mal" class="reviewlink" text="Bluehost" /]

A link to Fundrise merchant with the link “click me”.

[mal_link merchant="fundrise" child="link3" text="click me" /]

A button to merchant Personal Capital

[mal_button merchant="personalcapital" child="button1" text="Personal Capital" /]

Embedding an image

[mal_link merchant="bluehost" child="ltb4"]<img src="https://millennialmoneyman.com/wp-content/uploads/Select-the-BASIC-plan-1-768x612.png" alt="Select Bluehost Plan">[/mal_link]

Changelog

  • 1.0.7
    • Added support to allow for different separators of the child tag. Either ‘-‘ or now ‘/’ between merchant and child, which will allow more flexibility with services like ClickMeter which allows for ‘-‘ in their links.
  • 1.0.6
    • Added encode option to default true to esc_attr is used for the text attribute
    • Shortened the shortcodes to mal_link, mal_button and mal_amazon can be used (and preferred)
  • 1.0.5
    • Added default support for Google’s rel=”sponsored” tag
  • 1.0.4
    • Minor documentation changes
  • 1.0.3
    • Renamed shortcodes to begin with mal_ to comply with the WordPress plugin gods.
  • 1.0.2
    • The first version submitted to WordPress plugin directory.
  • 1.0.0
    • Initial version