Today, most bloggers are trying to make money from their blogs, and affiliate links are a great way to do this. Affiliate links are when you link to a product on your blog or website, and when your readers click through and buy that product, you receive a small percentage or commission on the sale. If you have enough traffic this is a great way to earn money.
But, there’s a small catch. It is illegal to include affiliate links in your posts without disclosing it to your readers. These legalities are understandable, because readers deserve to know that you aren’t just promoting the product because you think it’s great, but also because you are receiving a payout for it. Now in cases like mine, I still only promote products that I think are great, but it’s still necessary to disclose it to your readers.
So, how do you disclose it? The rules explain that you need to have a disclaimer, and you need to include it before the affiliate links themselves. This causes a problem because if you put text at the beginning of your text in WordPress, it automatically would be included in the post preview and the excerpt, and we don’t want the affiliate disclaimer included in that.
The second issue is that if you use a lot of affiliate links, you don’t want to have to manually copy and paste and insert it into every post. So, how do we make it easy to add an affiliate link, before the content, in a place that won’t be in the way of your content?
Enter, advanced custom fields. It’s easy, it will take you about ten minutes to set up, and after that you will be able to add an affiliate disclaimer to any post with the click of a button. This is how you do it.
In my WordPress design tutorials, Step 1 is always to create a child theme. If you have one already – then great – bypass this step. But, if you don’t have a child theme, you need to stop right now and read my post – How to make a child theme & why you need one. In a nutshell, a child theme allows you to create a safe place to put all your design changes so you never risk breaking your theme and your edits are never lost. Follow the steps in that post to create the child theme, and then you can come back here and continue on with this tutorial.
If you don’t already use the Advanced Custom Fields plugin, install it. Advanced Custom Fields allows you to add custom fields to any post or page on your site.
Click on Custom Fields in the toolbar on the left. You will then be brought to a page of Field Groups. Field Groups are essentially groups of fields that you can target to posts or pages by certain types. For example, you can say that every time you categorize a post under ‘blog’ you want a certain field to appear, or every time a page uses the template ‘full width’ you want other fields to appear. So these groups let us target things.
Create a new Field Group called Affiliate Disclaimer. If you think you might want to come back and add more fields to appear on every post, name it something more general like Standard Posts.
Under Location you will see the conditions that specify how to determine which posts appear where. The default is already set to every post, so you can leave it as is since that is what we want.
Next you will see a table, and this is where you add fields. Click Add Field. Under Field Label enter Affiliate Disclaimer.
It will automatically populate the Field Name with affiliate_disclaimer. This is the backend name of the field that you will need later.
Under Field Type select Checkbox.
Under Choices put Display Affiliate Disclaimer : Display Affiliate Disclaimer.
This means that there will be one checkbox, and the option will be Display Affiliate Disclaimer. You can either check the box to display it, or leave the box unchecked.
Lastly, you can set a default. If you use affiliate links a lot and want to automatically have the disclaimer there (but still have the ability to turn it off) you can set the default to be for the disclaimer to show. To do this enter Display Affiliate Disclaimer in the Default Value section.
So far we have created the custom field in the backend and configured it. Next we have to make it show up.
Log in to your FTP client. Go into your parent them and find the file responsible for single posts. In most cases this file should just be called single.php or something like it. Copy this file and paste it into your child theme.
Next, open the file. Paste the following code before the loop starts.
If your Field Name was different than affiliate_disclaimer when you created the custom field, you need to change this code to match yours. It’s just the once instance at the beginning. To double check what your field name is, go to Custom Fields, click edit on the field group you just created, and then look at the field name under the field you just created.
This code means ‘hey, when I check the Affiliate Disclaimer checkbox, show this text here.’
Next, spice up your disclaimer. Don’t leave it as just a boring one liner, add some flare.
I’ve also wrapped the disclaimer in a div incase you want to style it. I made mine so that it’s italic and a little smaller than the rest of the body text, so it doesn’t stand out too much, and readers can tell it’s not part of the actual content, though it’s still visible and easy to see.
Alternatively, you could decide to just include a short affiliate disclaimer, with a link to a more in depth explanation. And if you really wanted to get fancy you could create an image with the disclaimer in it, and make it what displays when you check the box. That way, the text itself is never seen or extracted as part of your content by the Google Bots.
Finally, to see if what you did is working, create a new post. You should now see an Affiliate Disclaimer section on your post editor page. Check the box, and then preview the post. You should see the disclaimer text you included now display at the top of the post.
Now that you’ve spent a little bit of time setting this up, it means that you can add an affiliate link to any post with just the simple click of one button. This makes using affiliate links and making money from your blog that much easier. Good luck!