This code enables you to add text for a affiliate disclosure to single posts in any Genesis child theme.
Based on the following question from a member of the Genesis community :
I would like to know how I can automatically add a sentence that appears immediately after my blog title and post data. I want it to say “This page may contain affiliate links. See our disclosure policy for more info.” Does anyone know where you add this text in the theme editor in order to get it to show up? I’m using the Smart Passive Income Pro theme. Thanks in advance!
Using a code editor and FTP, add the following PHP code to the end of your child themes functions.php file.
add_action( 'genesis_entry_header', 'affiliate_disclosure', 12 );
function affiliate_disclosure() {
if ( is_singular( 'post' ) ) :
echo 'Hello World';
endif;
}
Change Position
You can change the genesis_entry_header hook to change the position of your disclosure text.
In the following code, the genesis_entry_header hook has been changed to genesis_entry_content.
add_action( 'genesis_entry_content', 'affiliate_disclosure', 5 );
function affiliate_disclosure() {
if ( is_singular( 'post' ) ) :
echo 'Hello World';
endif;
}
Or, you can change the 3rd parameter in the code to a higher or lower priority :
add_action( 'genesis_entry_header', 'affiliate_disclosure', 5 );
function affiliate_disclosure() {
if ( is_singular( 'post' ) ) :
echo 'Hello World';
endif;
}
Add Link
You can also add some text and link it to another page like this :
The above code uses printf
Was This Tutorial Helpful?