Add an Affiliate Disclosure Statement without a Plugin (using Advanced Custom Fields)

Affiliate Disclosure Statement w/ Advanced Custom Fields

WP Smackdown is made possible by advertising & affiliate revenue. Eventually, we plan to offer video courses, sell ebooks, and possibly go down the membership route to offer up paid content. But for now, affiliates help keep us in the business of writing great content.

The FTC is very clear on disclosing the relationship that people & businesses have with affiliates, especially when it comes to writing reviews and/or recommending products (both of which we do on this site). In addition to abiding by the rules that the FTC has put in place, we want to be completely transparent & honest with our readers. With that being said, you might see an affiliate disclosure statement at the top of some articles.

Before We Start

When thinking about how to setup our affiliate disclosure statement, we pondered the following:

  • Should we use the same language on every page, or modify the disclosure based on the article content?
  • If the FTC changes their rules, or we decide to change the disclosure, how easy will it be to update everywhere?
  • How do we honestly & obviously display a disclosure without it getting in the way of our actual content?
  • How can we say what we need to say… keep it short… and still provide the full details behind our relationship with affiliates?
  • What tool(s) should we use to implement our disclosure?

Our Solution: Advanced Custom Fields (ACF)

With all of these questions answered, we decided on Advanced Custom Fields for implementing our affiliate disclosure statement. We chose it because…

  • we already use it for other things
  • it’s incredibly well-built, popular, and supported
  • it allows for a global implementation, but is flexible enough to allow for custom messages down the road
  • we fully control the markup & styles
  • it wouldn’t take much time to setup

Creating an Affiliate Disclosure without a Plugin, using Advanced Custom Fields (ACF)

1. Setup a new field in ACF

Affiliate Disclosure ACF Settings Page
The ACF settings for our affiliate disclosure. Click image for full size
  1. Navigate to Custom Fields > Custom Fields
  2. Add a new field group. We chose to name it “Affiliate Disclaimer.”
  3. You’ll want to use the following settings:
    • Field Type: Checkbox
    • Required?: No
    • Choices
      • yes : Yes
    • Layout: Horizontal
    • Set your Location settings to whatever meets your needs. We are just showing it on all articles with a post type of “post.”
    • Options are completely up to you

After saving those settings, you should end up with something like this:

Affiliate Disclosure Meta Box
The affiliate disclosure statement meta box on the post edit screen

2. Add the Affiliate Disclosure in your Template

Now that we have the field showing on our post edit screen, we have the option to check Yes. Now we need to tell our template to output some markup if Yes is selected. We added the following code to our single.php template, just before the call to the_content().

<?php /* insert affiliate disclosure */
$affiliate_disclaimer = get_field( 'acf_affiliate_disclaimer' );
if( in_array( 'yes', $affiliate_disclaimer ) ) { ?>
	<p class="disclaimer"><strong>Disclosure:</strong> This page contains affiliate links. If you purchase a product from one of our links, we could receive a commission from the seller. Rest assured, we only recommend products we believe in, and all opinions are 100% truthful. <a class="nowrap" href="/legal/#affiliate"><small>Learn More &raquo;</small></a></p>
<?php } /* end affiliate disclosure */ ?>

A few notes about the code

  • The $affiliate_disclaimer variable can be set to whatever you want. Just make sure you use the same variable within the if() statement.
  • acf_affiliate_disclaimer must match the “Field Name” set in ACF
  • Feel free to customize your markup. We chose to keep things simple: <p> tag with a class of “disclaimer”
  • Add whatever styles you need to your theme’s style.css file

3. The Result

Here’s what our affiliate disclosure looks like.

Affiliate Disclosure Example
This is how our affiliate disclosure looks

Notes about our disclosure

  • We followed the FTC’s guidelines in keeping the font-size the same as the main content, as well as highlighting it in some way (blue border)
  • We added an additional hover style to make it stand out more, but only when the user was interacting with it
  • Because we wanted to include more information, but not get in the way of the article’s main content, we added a “Learn More” link. We used CSS to only show this link when the user seemed interested in the disclosure (by hovering over it).

If you’re not using an affiliate disclosure statement on affiliate articles, I highly recommend you do so. As affiliate marketing becomes more and more popular, the FTC is cracking down on publishers who aren’t following their guidelines.

Are you using a plugin to display your affiliate disclosure statement, or did you opt for the non-plugin route? Please share your ideas & setup in the comments.

6 Commentson "Add an Affiliate Disclosure Statement without a Plugin (using Advanced Custom Fields)"

  1. /

    Great article and solution – it got me about 90% to where I want to be. However, can you add any insight on how you created your formatting with CSS? Thanks!

    → Reply
    1. (Author) /

      Hi Angela — Sure. I’d be happy to.

      I added a class of “disclaimer” to the <p> tag, and then I applied CSS styles to that class in my stylesheet.

      You can see the “disclaimer” class applied here:

      <p class="disclaimer">

      From there, you would then open up your stylesheet (style.css)—or use the Customizer’s “Additional CSS” feature—and add the styles you want. I would recommend using a little bit of padding, and then either a background-color or border… or both. Aside from padding, the rest is up to you. Here’s an example that would create a green background color with white text:

      .disclaimer {
      	padding: 0.75rem 1rem;
      	background: #00a886;
      	color: #fff;
      }

      Please let me know if that answers your question, or if you need any further help.

    2. /

      Thank you so much for the followup! That was exactly the help I needed. :) You rock!

  2. /

    Good tips, thank you. I had an error when I tried to implement this though.

    Warning: in_array() expects parameter 2 to be array, boolean given

    I was able to fix it by changing the output in ACF to TRUE : Yes and changed the third line of code to:

    if( $affiliate_disclaimer ) { ?>

    This way, I was creating a TRUE/FALSE in $affiliate_disclaimer and doing a simple if statement.

    Thanks!

    → Reply
    1. (Author) /

      Thanks for chiming in, Karl. I’m not sure why I’m able to get it to work and you were getting an error, but I’m glad you figured it out. And thanks for sharing your solution for others who might run into the same issue.

    2. /

      Hi, Karl! Can you please copy paste the whole code you used? I have the same problem, but can’t figure it out. Thanks a lot! Violet.

What Are Your Thoughts?

All fields are required. Your email will not be published.

You can use standard <code> and <pre> tags to post code examples, or a service like codepen.io.