5 Easy Ways To Add Affiliate Disclosures In WordPress

This post contains affiliate links. Which means I will make a commission at no extra cost to you should you click through and make a purchase. Read the full disclosure here.

Keeping your blog legal is a tricky learning curve when just starting a blog. One important aspect is making sure you have affiliate disclosures. Which need to be at the top of any blog post that includes affiliate links.

Sometimes you might even need to add a disclosure to the top of each blog post for other reasons. Like disclosing a sponsored post, for example.

But the problem with all these legal requirements for us bloggers. Is not just knowing what to do to stay legal. The how we do it, is also vital too.

After all, if you had to go back through every blog post you wrote. And add in a little affiliate disclosure at the top. It would probably take a lot of time. Even if you just copied and pasted it.

Well, that’s where this blog post comes in. As I’m going to cover several different ways on how to add an affiliate disclosure using WordPress. Including the advantages and disadvantages of them.

Before we get into the how. Let’s have a quick explanation of the what and why.

5 Easy ways to add affiliate disclosures in WordPress

What Are Affiliate Disclosures & Why Are They Important?

Ever noticed the line of text at the top of many blog posts. That says something along the lines of how “the blog post contains affiliate links”. And that if you click on them, that “the blogger might be compensated at no extra cost to you”?

Well, that’s exactly what an affiliate disclosure is. And they are an important legal requirement. For all bloggers that use affiliate links in their blog posts. So that it is clear and transparent when we as bloggers are being compensated for our work. And how exactly.

What You Need To Know About Writing A Disclosure

Writing an affiliate disclosure can sound complex. And sure enough, there is more than one way to go about writing them. Which is why it is important to understand things like the FTC guidelines.

And if you prefer to see examples. Then this blog post by Simply Stacie has some really easy to understand examples. That you can use as a reference.

But before you create an affiliate disclosure. You need to create your policy documents first. As your disclosure needs to link back to it. Writing this can be daunting and plain ol’ boring. But if you are serious about blogging. Then this needs to be done!

So, if you haven’t done this yet, I recommend reading this post. As it is full of useful tips. Or getting professional templates from a lawyer blogger here.

Warning! Before following any of the below methods. Backup your WordPress blog! As some of these methods will require editing your core theme files. Which could break your blog if done incorrectly!

Using Copy & Paste Every Time You Want To Add Affiliate Disclosures

Okay, so the most common option you could use to add an affiliate disclosure to your WordPress blog posts. Is that you could have a copy of the text and link saved somewhere. That you could then just copy and paste each time.

This method requires no tools. But as I mentioned earlier. It is clunky, slow and repetitive. It also relies on you remembering to copy and paste the disclosure in when needed.

Which is why I ended up looking for better alternative solutions!

Using A Shortcode To Create Affiliate Disclosures

Using a shortcode could help you save some time. Since you only have to remember something short like [disclosure]. You also don’t have to go looking for your copy and paste files either.

You’ll also be glad to know. That this method will work in both the Classic and Gutenberg editors.

Firstly, for this method. Go to Appearance > Theme editor

Under Theme files on the right-hand side click on Theme functions (functions.php) file.

Then at the bottom of the file, like here:

Where The Code Should Go When Pasting The Affiliate Disclosure Into The Functions.php File

Copy and paste the below code:

/* Custom affiliate disclosure shortcode */
function disclosure() {
    return "<p class='disclosure'>This post contains affiliate links. <a href='https://www.individualobligation.com/disclosures/'>Read the full disclosure here</a>.</p>";
add_shortcode( 'disclosure', 'disclosure' );

Change the URL to point to your disclosures page. You can also change the rest of the wording if you like.

Click Update file at the bottom to save your changes.

Now if you are using the Classic WordPress editor or even WordPress Gutenberg. You should be able to simply type [disclosure] wherever you want this shortcode snippet to appear!

Much to my surprise. You don’t even have to create a shortcode block. To enter your [disclosure] shortcode for it to work in the WordPress Gutenberg editor.

Just make sure you test it out with a quick preview. Before publishing to make sure everything is working first though!

How To Use A WordPress Gutenberg Reusable Block For Your Affiliate Disclosure

Another option, only available if you use the Gutenberg editor. Is that you could create a reusable block.

Simply create a regular paragraph block. Add in your text, a link to your policy page. And perhaps a background color to help separate it from the rest of the blog post. Like this:

What A WordPress Gutenberg Reusable Block Looks Like When Setup As A Disclosure Statement

You can then click on More Options for this Paragraph block and click Add To Reusable Blocks. Give it a memorable name and save it. Then whenever you add it to a blog post. It is all written and formatted for you. And what’s better. Is that if you decide to change the format, wording or link. It will update across all versions of this reusable block you’ve used throughout your blog posts. Cool, huh?

Again, the problem with this is that you have to remember to add in the reusable block. Every time you write a blog post that contains an affiliate link. But let’s be honest, as bloggers, we have too much to remember already. Without adding something like this on top of it all.

It also has the issue that it doesn’t apply backwards. So if you have say, 50+ blog posts you’ve written already. You’d have to go back and manually add the reusable block affiliate disclosure to each blog post. What a time sink!

Using Your Blog Post Tags To Automatically Trigger Your Affiliate Disclosures

Right, so the next option requires a little bit of editing your WordPress Theme. By adding some code. It’s a little scary. But should be easy to follow. Just make sure to backup your blog first.

If you are curious what the end result will look like. Before you go through the trouble of editing your WordPress Theme. Then here’s a quick screenshot below. Which shows the affiliate disclosure just below the social sharing buttons.

Example Of Affiliate Disclosures Under Social Sharing Buttons For Added Theme Code

So, how do we get this result? Start off by going to Appearance > Theme editor. And on the right-hand side select the Theme functions (functions.php) file.

Scroll to the very bottom of this file and paste in the below code:

/* Add Affiliate Disclosure to Posts with the Tag Affiliate Only */
function disclosure_the_content( $content ) {
     if (is_singular('post') && has_tag( 'affiliate' )) {
         $custom_content = '<p class="disclosure"><i>This post contains affiliate links. <a href="https://www.individualobligation.com/disclosures/">Read the full disclosure here</a></i></p>';
         $custom_content .= $content;
         return $custom_content;
     } else {
         return $content;
add_filter( 'the_content', 'disclosure_the_content' );

To customize this code for your own blog. You should change the “https://www.individualobligation.com/disclosures/”. To your policy page’s URL.

You can also customize the “This post contains affiliate links. ” and “Read the full disclosure here” text. To your own custom wording.

Once you’ve customized everything click Update File. And check the results on your blog.

So, how does this code work? Well, it will add in an affiliate disclosure to every blog post that you give the tag “affiliate”. The main problem with this is that although you can control the disclosure on a post by post basis. You still have to rely on yourself to remember to add the affiliate tag in the first place. Which could land you in trouble if you forget.

So, either add this step to your blog post checklist. Or I would strongly suggest using the following section instead. Which will show you how to add an affiliate disclosure to every blog post. That you can simply set and forget.

Also, if you would like to style the disclosure with different formatting using CSS. You can simply target the class=“disclosure”

How To Automatically Add An Affiliate Disclosure To Every Blog Post

Okay, so here’s how you can add an affiliate disclosure to every blog post that you won’t have to remember!

Remember how we added some code to the bottom of the functions.php file? Well, this is exactly the same here.

So, go into the Appearance > Theme editor from your WordPress Dashboard. And on the right-hand side select the Theme functions (functions.php) file.

Add the below code to the bottom of the file:

/* Add Affiliate Disclosure To All Posts */
function disclosure_the_content( $content ) {
    if (is_singular('post')) {
        $custom_content = '<p class="disclosure"><i>This post contains affiliate links. <a href="https://www.individualobligation.com/disclosures/">Read the full disclosure here</a></i></p>';
        $custom_content .= $content;
        return $custom_content;
    } else {
        return $content;
add_filter( 'the_content', 'disclosure_the_content' );

Again, you’ll want to customize the URL in the code to your own policy page. And change the text wording depending on your needs.

How To Add Affiliate Disclosures Automatically To All Blog Posts With A Plugin

The above methods are how I would suggest adding affiliate disclosures to your blog posts. However, for those of you who would rather use a WordPress plugin. Or prefer not to edit code in your WordPress Theme files. I have an alternative you might be interested in 😉

Whilst there are many WordPress plugins out there. Finding one for affiliate disclosures is a little tricky. Simply searching for things like disclaimer or disclosure. Will likely lead to a handful of relevant plugins. Most of which aren’t very popular, well-supported or user-friendly.

Which is why I’m actually going to suggest something a bit different.

So, to start off for this method you’ll want to go and install the WordPress plugin called Ad Inserter.

Ad Inserter Plugin To Download For Adding Affiliate Disclosures To Blog Posts

Yep, that’s right. This WordPress plugin might have been designed for things like Google Ads. But it also makes a great affiliate disclosures plugin once you know how to set it up.

So, once you have it installed. Go to Settings > Ad Inserter from the WordPress dashboard.

Wordpress Plugin Ad Insert Settings Option To Add Affiliate Disclosure To Blog Posts 1

On this screen, in the black box copy and paste the below code:

<p class="disclosure"><i>This post contains affiliate links. <a href="https://www.individualobligation.com/disclosures/">Read the full disclosure here</a>.</i></p>

Below the black box make sure the tick next to Posts is visible.

Change the Insertion to Before content.

And Alignment to Center or Left depending on your preferences.

Remember to customize the URL with your own policy page. Plus any other changes to the wording of the disclosure.

Ad Inserter Plugin With Affiliate Disclosure Code Added And Setup

Then click Save All Settings.

If you then browse to your blog posts. You should see your affiliate disclosure appearing above your social media sharing buttons. Like this:

Example Of Affiliate Disclosures Above The Social Sharing Buttons When Using Ad Inserter WordPress Plugin

And if for any reason you want to disable this affiliate disclosure. Then you simply need to click the pause icon that is near the top right. And then click Save All Settings again.

It should turn red and look like this:

If You Need To Pause The Ad Insert Click This Button Here

Adding An Affiliate Disclosure To Your Blog Post Is Easy With These WordPress Tutorials

Including an affiliate disclosure is an essential task. That every beginner blogger needs to do. Before you start adding affiliate links to your blog posts. And trying to monetize your blog.

Whilst getting your head around the legal requirements of your affiliate disclosures. And policy pages, can be a tricky process. I hope that this WordPress tutorial. Will make the technical side of actually adding them to your blog posts. Super easy and a breeze to do.

After all, there is hopefully a method included here to fit all your blogging needs. Whether you would rather use a WordPress plugin. Edit code or control your affiliate disclosure on a post by post basis.

So, tell me – what’s your preferred method for adding an affiliate disclosure to your blog posts? Are there any types or styles of affiliate disclosures not included here that you’d like to see?

If you found this blog post useful then please consider taking a few seconds to share it to your favorite social media platform!

5 WordPress tips to add an affiliate disclosure like a Pro

25 thoughts on “5 Easy Ways To Add Affiliate Disclosures In WordPress”

  1. HI, I’ve added the code to the bottom of my functions file for it to appear on every post automatically, however it’s the standard location of at the top under the article H1 title. I’d love to be able to move it further down. Is this possible? Thanks so much.

    1. Hey Kerri,

      How much further down were you looking to move it? It’s important to make sure your disclosure is shown before any affiliate links in your blog posts.

      I’ve seen some bloggers add their affiliate disclosure a few paragraphs down into the blog post. But still before any affiliate links were mentioned. You would have to use either the shortcode or the Gutenberg reusable method to achieve this though. If that is what you are looking for?

  2. Hi yes Lisa, Was looking for it to appear like this, not under the heading, but still before the first affiliate link so shall try the shortcode. Cheers.

    1. Hey Silvu,

      You can try adding an image by inserting an < img > tag. Like this:

      < img src="your-image-URL.jpg" width="100" height="100" alt="Describe your image">

      You can add it before or after the original code. You’ll need to remove the space before “img”. WordPress comments don’t seem to like me pasting code 🙁

      Make sure to:
      Set the image src= to the URL of your image
      Change width= and height= to the size of your image
      Edit alt= to briefly describe your image
      Change href= to your disclosure page’s URL

      I hope this helps!

  3. Hello, thank you so much for sharing, it helped a lot! I’m using the last option with the ad plugin and would like to change the text size. I tried to add it myself to the code but it didn’t work. Is this something you could help me with? Thanks.

    1. Hey Sara,

      Try adding this just after the < p in the code: style=”font-size: 20px;”

      Change the “20px” to whatever size you’d like.

      If the size doesn’t appear to change make sure you:
      -Clear any cache plugins
      -Open the post you’re checking in an incognito/private tab

      I hope this helps! Let me know how it goes 🙂

  4. Hi there! Can you share which method you used to create your affiliate disclosure at the top of this blog post? I love how it looks and would want it to go right after the H1 heading too!

    1. Hey Michelle,

      You’ll want to use the Genesis Simple Hooks plugin.

      My current Theme is actually Astra so my code needs a little editing to get it to work for your Genesis Theme.

      But if you grab the code below and open up the Genesis Simple Hooks plugin. Then paste the code into the box under the *genesis_entry_header hook* and make sure that *Execute PHP on this hook?* is enabled. It should -hopefully- work.

      (Remember to click Save Changes)

      Here’s the code:

      if (is_single($post)) { 
      		echo '<p id="aff_disclose">This post contains affiliate links. Which means I will make a commission at no extra cost to you should you click through and make a purchase. Read the full disclosure <a href="https://www.yourURL.com/disclosures/">here</a>.</p>';

      To format it further you’ll then want to go to Appearance > Customize > Additional CSS and then paste in the following as well:

      #aff_disclose {
      	text-align: center;
      	color: #737373;
      	font-size: 0.7em !important;
      	line-height: 1.2;

      Let me know if you have any questions and I’ll do my best to help 🙂

  5. Hi Lisa, thanks for this helpful post! I tried a few of these methods, but found that the method here with the Genesis Simple Hooks was the closest to what I wanted. It’s almost perfect but I’m hoping you can help me tweak it.

    First, the part of the code that should make it only show up on posts wasn’t working. The code was showing up where the text should be. If I add (is_single($post)) { I can see it before the disclosure. So now, of courese, the message is not only showing on the posts – but it’s also showing on the home page and other pages.

    Second, is there any way to put it under my author byline/date instead of above it? Is there a different hook for that?

    I ended up only leaving this code in the simple hooks box:

    This website contains affiliate links. If you click a link and purchase something, I may receive a small commission (at no extra cost to you). Please read my full disclosure here.

    I put this in the genesis_entry_header hook section.

    Here’s what it looks like on a recipe post: https://insearchofyummyness.com/pan-fried-dumplings-potstickers/

    And my homepage: https://insearchofyummyness.com/

    1. Hey Shareba,

      Try looking for the “genesis_before_entry_content Hook” if you want the disclosure after author/post date.

      Ensure that “Execute PHP on this hook?” is enabled.

      Paste in the following code:

      if (is_single($post)) { ?>
      <p id="aff_disclose">This post contains affiliate links. Which means I will make a commission at no extra cost to you should you click through and make a purchase. Read the full disclosure <a href="https://www.yourURL.com/disclosures/">here</a>.</p>
      <?php } ?>

      Remember to save the changes using the button further down below the hook.

      You can then go to Appearance > Customize > Additional CSS and tweak the below code to format the font/size/color etc.

      #aff_disclose {
      	text-align: center;
      	color: #737373;
      	font-size: 0.7em !important;
      	line-height: 1.2;

      Hopefully that will get everything working for you 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stop these 57 common mistakes from holding back your WordPress blog with this FREE Checklist:TAKE ME TO IT!