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.
Again, if you do not have a child theme, you need to make one before continuing. If you do have a child theme already, log into your FTP. Navigate to your themes folder by going to wp-content > themes. There you will see all the themes installed on your site. You should see your parent theme (the theme you based your child theme on) and your child theme (the theme you created).
Go into your parent theme folder and find the file responsible for single posts. In most cases this file should just be called single.php or something along those lines. You will see in the image below the single.php file that I am referencing is highlighted. Twenty Sixteen is my parent theme, and the single.php file is within it.
Open this file in your text editor and copy all of the content within in. Also take note of the name of the file.
Then go back into the themes folder and go into your child theme folder. Right click and make a new file, and name it the exact same thing as the single file you were just in. Save the file, and then open it and paste all the content you copied into it. You will see in the image below the single.php file that I have just created in my child theme.
Within the file you will see different elements of code. You want to paste the following code before the loop starts. If you don’t know what the loop is, that’s okay. Depending on your theme it might even say ‘the loop’ like it does in mine. If it doesn’t you want to paste this code at the very beginning of the main div. So you will see a div in this picture below called ‘content’. So that is the main div (or box) that all your site content is in, so you want your disclaimer to go in there as well.
This code means ‘hey, when I check the Affiliate Disclaimer checkbox, show this text here.’
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 one 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.
Next, spice up your disclaimer. Don’t leave it as just a boring one liner, add some flare. You obviously don’t want your disclaimer to be the exact same as mine, so you should change it up and make it unique to you. After you’ve made any changes save the file.
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!