• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Add Affiliate Disclosure After Single Post Entry Titles In Genesis

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

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags