In Genesis Facebook group a user asks:
Hi everyone I’m wondering which genesis hook are would be best for a blanket affiliate links disclosure across by blog posts on my blog. They need to be at the top for Australia but I don’t want them being in my excerpts.
We can add custom HTML content above the content using the genesis_before_entry_content
action hook and restrict it to single Posts using an if conditional.
Step 1
Add the following in child theme’s functions.php:
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;
} ?>
<div class="affiliate-disclosure-notice">
<p>This post may contain affiliate links. <a href="#">Click here</a> to find out more about this.</p>
</div>
<?php }
Change the HTML to your desired content.
Step 2
Add the following in child theme’s style.css:
.affiliate-disclosure-notice {
margin-bottom: 30px;
padding: 12px;
border: 1px solid #e2e2e2;
background-color: #eee;
font-size: 16px;
font-style: italic;
text-align: center;
}
.affiliate-disclosure-notice p:last-child {
margin-bottom: 0;
}