Last active
October 22, 2018 20:30
-
-
Save kriot1/d2e05ab52d64142588a8227db4447a5f to your computer and use it in GitHub Desktop.
Affiliate Disclaimer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.affiliate_disclaimer { | |
background: #f5f5f; | |
color: #000; | |
border-radius: 3px; | |
margin: 0 2px 20px; | |
padding: 10px 20px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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