Back to top

Affiliate Link: Looking to Monetize With Ads?? We Personally Use:

Ezoic

Add Amazon Disclaimer Prior To Your Content With Code Snippets

As an Amazon Associate we earn from qualifying purchases made on our website. If you make a purchase through links from this website, we may get a small share of the sale from Amazon and other similar affiliate programs. You can read our complete legal information for more details.

Earlier this week we spoke about adding a disclaimer before content with Custom CSS only. This has limits due to different post types and it has no ability to be linked outside of the text you provide.

As the CSS version was being built I was building a code-based version that could be used on all single posts and would give you the ability to add pages to the snippet.

YouTube

By loading the video, you agree to YouTube’s privacy policy.
Learn more

Load video

You will need to install the Code Snippets plugin which adds no bloat and allows you to structure and name additions to your site for easier management.

Once installed you will want to download the file here, then inside Code Snippets run the “Import”. This will add the entire snippet to your website.

You will want to find the page section and modify it to add any pages you need a disclaimer on, you can use the number or the slug name in single quotes. (The ones on there are examples to replace)

if(is_page( array( 234, 'about-me', 'Contact' ) ) || is_single()) {

Then you can make changes to the CSS below to ensure it displays how you would like it to.

.affiliate {
    display: block;
    align-content: center;
    font-family: "libre_franklinregular",sans-serif;
    margin: 30px 30px 30px 30px;
    padding-top: 30px;
    padding-bottom: 30px;
    text-align: center;
    font-size: 14px;
    padding-right: 25px;
    padding-left: 25px;
    background: #ebfaff;

Then you can make changes to the legal disclaimer location if you want to link out. Just replace the below # sign with the website complete URL.

<a href="#">

If you don’t want to link out replace:

<a href="#">legal information</a>

with

legal information

These display on the pages with schema within Acabado also so you have the banner across your recipes, products, etc.

Version Which Show Affiliate Disclaimer Only On Specific Post With Tag

This you can change out page id’s for your resource pages to have a disclaimer (separate each with commas) or use the page name if you enclose like the below in code examples.

Additionally the has_tag code allows you to change to a tag name you want by default it is added to any post with the tag “Affiliate” added to it.

/**
 * Append Content Before Posts For Affiliate Disclaimer.
 * Optional commented out after content section where you could add additonal CTA ation if you chose
 */
function wpcontent_before_after($content) {
	if(is_page( array( 234, 'about-me', 'Contact' ) ) || is_single() && has_tag('Affiliate')) {
		
    $beforecontent = '<div class="affiliate">As an Amazon Associate we earn from qualifying purchases made on our website. If you make a purchase through links from this website, we may get a small share of the sale from Amazon and other similar affiliate programs. You can read our complete <a href="#">legal information</a> for more details.</div>';
    #$aftercontent = '<div class="affiliate">And this will come after, so that you can remind them of something, like following you on Facebook for instance.</div>';
    $fullcontent = $beforecontent . $content . $aftercontent;
    
	} else {
        $fullcontent = $content;
    }
    return $fullcontent;
}

add_filter('the_content', 'wpcontent_before_after');

add_action( 'wp_head', function () { ?>
	<style>

	.affiliate {
    display: block;
    align-content: center;
    font-family: "libre_franklinregular",sans-serif;
    margin: 30px 30px 30px 30px;
    padding-top: 30px;
    padding-bottom: 30px;
    text-align: center;
    font-size: 14px;
    padding-right: 25px;
    padding-left: 25px;
    background: #ebfaff;
}
	</style>
<?php } );

About Josh Koop

Hey Everyone! I hope that the short article you read today has taken you from a place of frustration to a place of excited anticipation for your visitors! Please let me know of anything you need for Acabado that can help you achieve your goals!

My Posts | Website

Josh Koop

Hey Everyone! I hope that the short article you read today has taken you from a place of frustration to a place of excited anticipation for your visitors! Please let me know of anything you need for Acabado that can help you achieve your goals!

6 thoughts on “Add Amazon Disclaimer Prior To Your Content With Code Snippets

  1. Thanks for this tip, Josh.

    I added it but noticed on mobile it was a tall and narrow block (at least on my Android). I ended up modifying the padding as follows (and the text a little) which shows up a little nicer on both mobile and desktop:

    .entry-content::before {
    content: ‘As an Amazon Associate I may earn a small comission from qualifying purchases if you click to Amazon from my site and choose to make a purchase. You can read my complete affiliate disclosure for more details.’;
    display: block;
    align-content: center;
    font-family: “libre_franklinregular”,sans-serif;
    margin: 0px 10px 10px 10px;
    padding-top: 10px;
    padding-bottom: 10px;
    text-align: center;
    font-size: 9px;
    padding-right: 20px;
    padding-left: 20px;
    background: #ebfaff;
    }

    1. I am going to update it with media queries so it is responsive across all platforms, I overlooked it before so I appreciate it!

      šŸ˜‰

  2. Josh, I really appreciate your work. Shouldn’t some of these fixes be included in Acabado download? If it is not compliant, I’m sure Jim and Ricky would fix it. I don’t find the theme to be very intuitive and have had a lot of trouble with it. Even though I paid for 100 years, I’m not sure if it’s worth keeping.

    I started getting Update Failed the response is not valid JSONResponse and had to change to classic editor to get around it. I can’t start a new paragraph in Legal (it appends the text instead of creating a new paragraph) with no obvious way to edit it, and all the images they included used up all the 100 Shortpixel optimizations for the month. A heads up would have been nice.

    I think Income School should pay you for support their product. It doesn’t look good for them to be putting out a product without providing any support.

    1. Update failed is because there is a timeout on the site between saves, I get it with any WordPress install and not just Acabado. Don’t leave the window open only on the post page if you arent frequently updating it.

      Legal is an HTML element, you would want to use HTML elements like
      to move text to another line.

      I hate to say you enable shortpixel and limit yourself to free use only then any demo content included with a theme would do the same. This is just on the user to not enable a image compression plugin when you aren’t wanting to compress the images.

      Well, I would like to add, did you watch all their setup videos? They cover all of their inbuilt features, I tend to bend it to other useful forms which they shouldn’t have to support. I will say it fits a specific need and not for all websites.

Leave a Reply

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

Recent Content