• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Blog Monetization
  • Social Media
  • WordPress
  • Resources
  • Freebies
  • Nav Widget Area

    • Bloglovin
    • Facebook
    • Instagram
    • Pinterest
    • Twitter

Lovely Blog Academy

Lovely tips for growing and monetizing your blog

AFFILIATE MARKETING FREEBIES

Download my beginner's guide to affiliate marketing & my income tracking spreadsheet by signing up to my weekly email newsletter:

Thank you! Now check your email inbox

How to save time by putting your blog’s disclosure into a shortcode

How to put your affiliate link disclosure into a WordPress shortcode

Do you regularly add disclaimers and disclosures to your blog posts for sponsored posts, product reviews or to denote the use of affiliate links?  And do you use WordPress?

If you’ve answered yes to the questions above, we’re going to show you how to add turn that disclosure into a reusable shortcode.

What is a shortcode?

According to WordPress, “a shortcode is a WordPress-specific code that lets you do nifty things with very little effort.” Basically, a shortcode is a shortcut.”

Why put my disclosure/disclaimer in a shortcode?

To make life easy, of course!  This is a one time job that will save you typing out your disclosure and linking it to your ‘more information’ page each time you run a sponsored piece of content or use an affiliate link.  Instead, you’ll simply add the following shortcode into your content:

[disclosure]

That’s much easier to remember, right?  For this example, we’re using an disclosure to show readers we use affiliate links on the page.  You can customise this easily to output your message of choice – we’ll explain how below.

Instructions:

Open your theme’s functions.php file.  Create a backup of the file first and keep it somewhere safe.  Then paste in the following code (I usually paste at the bottom of the file).

1
2
3
4
5
6
7
 
//* LOVELYBLOGACADEMY.COM - AFFILIATE DISCLOSURE SHORTCODE
function aff_disclosure() {
return "<p class='disclosureLBA'>This blog post contains affiliate links. <a href='http://YOURDISCLOSUREPAGE.com'>Learn more</a>.</p>";
}
add_shortcode( 'disclosure', 'aff_disclosure' );
 

This registers a new shortcode with WordPress called “disclosure”.   When you use the new shortcode it will output your disclosure and a link to your disclosure page.

To start using the shortcode, you’ll add the following snippet at the top of your blog posts:

[disclosure]

Here’s the message it will output:

This blog post contains affiliate links. Learn more.

Want to customise it?  No problem…

Customising the disclosure shortcode:

  • To edit the wording, change the text between <p class='disclosureLBA'>  and </p> (e.g. “This is a sponsored post.  Learn more.”).
  • Swap "http://YOURDISCLOSUREPAGE.com"  for the URL to your site’s disclosure.
  • Use p.disclosureLBA  to style your disclosure in your CSS stylesheet. Here’s my sample styling, feel free to use:

1
2
3
4
5
6
7
8
9
10
11
12
 
p.disclosureLBA {
text-align: center;
color: #666;
text-transform: uppercase;
font-size: 10px;
}
p.disclosureLBA a {
color: #666;
text-decoration: underline;
}
 

This is the end result –

Disclosure: I use referral links in this post, I might make a commission on my recommendations. Learn more.

Simply paste the shortcode [disclosure]  into your next blog post.  Easy!

ADVANCED
Creating multiple disclosures:

If you run both sponsored posts and affiliate links, you may want to use TWO different shortcodes, each outputting different wording depending on the type of content you’re publishing.  That’s easy to do.

Simply add this to the bottom of your functions.php file –

1
2
3
4
5
6
7
 
//* LOVELYBLOGACADEMY.COM - SPONSORED DISCLOSURE SHORTCODE
function spon_disclosure() {
return "<p class='disclosureLBA'>Sponsored content. <a href='http://YOURDISCLOSUREPAGE.com'>Learn more</a>.</p>";
}
add_shortcode( 'sponsored', 'spon_disclosure' );
 

You’ll then use [sponsored] in your content to output the new disclosure.

Once again, customise until you’re happy with the output.

If you need to create MORE disclosures, change the function name spon_disclosure  to something of your choosing.  Make sure to replace both instances of it in the code.   Rename your shortcode (where it says ‘ sponsored ‘ in the last line) to something else too.  There’s no limit on how many shortcodes you can add to WordPress, so add as many as you require!

Adding the disclosure into a sidebar widget

You might have noticed that I have my disclosure right at the top of this page, on the right.  I’ve added it to my sidebar.  If you’d like to do this, you must enable shortcode compatibility for widgets first.  It’s really simple.  Once again, paste the following code into your functions file –

1
2
3
4
 
//* LOVELYBLOGACADEMY.COM - ENABLE SHORTCODES IN TEXT WIDGETS
add_filter('widget_text', 'do_shortcode');
 

Easy peasy.  Now head over to Appearance > Widgets and your shortcode into a text widget.  Done!

Helpful?  Share this with your friends:

Please tweet this tutorial so we can help other bloggers:

Learn how to turn your blog disclosure into an easy-to-use #WordPress shortcode. Simple! Click To Tweet

Alternatively, pin the image below:

Save time by turning your blog's disclosure into a resuable shortcode. LovelyBlogAcademy.com

Thank you!

2nd December 2015 1:40 pm Carly 5 Comments Filed Under: Monetizing your blog, WordPress

Any questions?

Leave a comment below, or head over to the LBA Community Facebook group.

Visit us on Facebook

Advertisement

Feminine WordPress Themes

Reader Interactions

Comments

  1. 1

    Grant says

    15th November 2016 at 3:35 am

    This was really helpful. I was trying to add multiple disclosures and kept getting stuck. Appreciate the tips.

    Reply
    • 2

      Carly says

      15th November 2016 at 9:50 am

      Hi Grant,

      I am pleased the tutorial helped.

      Carly.

      Reply
  2. 3

    The Eclectic Voyager says

    29th May 2017 at 3:28 am

    Awesome post! I just used it to create my disclosure and it was so simple. Thanks!

    Reply
    • 4

      Carly says

      23rd June 2017 at 11:05 am

      Very pleased to hear that! Thanks for the feedback 🙂

      Reply
  3. 5

    Rena says

    17th June 2020 at 8:43 pm

    When I type functions.php, it comes up as ad-funcitons.php. Is this where i stick the code?

    Reply

Leave a Reply Cancel reply

You have to agree to the comment policy.

Primary Sidebar

HI, I’M CARLY

If you're a blogger looking for helpful tips with a focus on monetization and affiliate marketing... you've come to the right place! ABOUT ME & THIS SITE

TRIED, TESTED & RECOMMENDED

Want to get started with affiliate marketing? I use and recommend SkimLinks. Install it and it'll monetize your content automagically. Works with ANY site:

SkimLinks

RECENT POSTS

  • Can I use Shopstyle Collective with WordPress.com?
  • Can I boost my Amazon Affiliate Links on Facebook?
  • How to add a ShopStyle Collective widget to your sidebar in WordPress
  • Can I post Amazon affiliate links to Pinterest?
  • FREE: Blog income tracking spreadsheet
  • A guide to using affiliate links on Facebook
  • How to monetize your WordPress.com blog
  • A beginner’s guide to WordPress security
  • 17 successful affiliate linking strategies you need to know
  • How to add links to image captions in WordPress

MORE FROM THE BLOG

Guide to affiliate marketing and promoting affiliate links on Facebook

A guide to using affiliate links on Facebook

How to manage mupliple Pinterest accounts using Google Chrome

How to easily manage multiple Pinterest accounts (for FREE)

Tips for affiliates/bloggers

17 successful affiliate linking strategies you need to know

AFFILIATE MARKETING FREEBIES

Join my community to get:

My beginner’s guide to affiliate marketing (5-page eBook)

My affiliate income tracking spreadsheet

Access to my private Facebook group (ask questions, share your blog etc)

My email newsletter once per week

Thank you! Now check your email inbox

Browse by category

  • Blogging Tips (1)
  • Design (2)
  • Monetizing your blog (15)
  • News (1)
  • Social Media (8)
  • WordPress (6)

COME SAY HI

  • Facebook Page
  • Facebook Group
  • Instagram
  • Twitter
  • Pinterest
  • Google+

FREE DESIGN GOODIES:

Powered by Creative Market

Useful pages

  • About
  • Contact
  • Content Archives
  • Resources / Credits
  • Advertise here?
  • Disclosure
  • Cookie Policy
  • Privacy policy

RESOURCES

ShopStyle Collective, Formally ShopSense

Here's a list of every tool, app, resource and piece of equipment that I personally use on this site (or on one of my other blogs) and recommend. The list is a mixture of free and paid resources. Disclosure:  I have used affiliate links to some of the ... Read this post

Footer

DISCLOSURE

This website is supported by adverts and affiliate marketing links. This means if you click a link and/or buy a product, I might earn a commission at no extra cost to you. These partnerships help pay for this site. Regardless of this, all opinions are my own. Read my FULL earnings disclosure here for more information.

As per the Amazon Operating Agreement I have to state that I (Carly Wood) am a participant in the Amazon Services LLC Associates Program and the Amazon EU Associates Programme. These are affiliate advertising programs designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.co.uk and amazon.com.

Learn more about paid advertising & affiliate marketing:
Visit: PaidForAdvertising.com

This site also uses cookies.
You can also read about cookies and how they affect you by clicking here. My privacy policy is located here.

  • About
  • Contact
  • Content Archives
  • Resources / Credits
  • Advertise here?
  • Disclosure
  • Cookie Policy
  • Privacy policy

© Copyright 2017 · CARLY WOOD · Lovely Blog Academy