Skip to content

Instantly share code, notes, and snippets.

@kriot1
Last active October 22, 2018 20:30
Show Gist options
  • Save kriot1/d2e05ab52d64142588a8227db4447a5f to your computer and use it in GitHub Desktop.
Save kriot1/d2e05ab52d64142588a8227db4447a5f to your computer and use it in GitHub Desktop.
Affiliate Disclaimer
.affiliate_disclaimer {
background: #f5f5f;
color: #000;
border-radius: 3px;
margin: 0 2px 20px;
padding: 10px 20px;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
// Add Affliate Disclaimer to post
add_action( 'genesis_before_entry_content', 'custom_affiliate_disclosure' );
/**
* Add custom affiliate link disclosure notice above the content on single Posts.
*/
function custom_affiliate_disclosure() {
// if this is not a single Post, abort.
if ( ! is_singular( 'post' ) ) {
return;
} ?>
<!-- Affiliate Disclaimer -->
<?php
// vars
$affiliate = get_field('affiliate_disclaimer');
// check
if( $affiliate && in_array('Display Affiliate Disclaimer', $affiliate) ): ?>
<div class="affiliate_disclaimer">This post contains affiliate links.</div>
<?php endif; ?>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment