Tutorials

Genesis to Kadence Code Snippets

(This post contains affiliate links. Read my full disclosure.)

Moving from Genesis to Kadence and need to replace some of your Genesis functions? Want to add a disclosure statement before your posts but don’t have the Elements available with Kadence Pro?

Install the Code Snippets plugin, if you haven’t already, and try these snippets that use Kadence Theme hooks to recreate what you were doing in Genesis.

add_action('kadence_single_before_entry_content', 'gl_before_entry_disclosure', 5);

function gl_before_entry_disclosure(){
	
	if ( is_single($post) && has_tag( 'affiliate' ) )  {
		echo '<center>(This post contains affiliate links. <a href="https://gretchenlouise.com/disclosure/">Read my full disclosure</a>.)</center>';
	}
}

add_action('kadence_single_before_entry_content', 'gl_before_entry_disclosure', 5);

function gl_before_entry_disclosure(){
	
	if ( is_single($post) && in_category( 'affiliate' ) )  {
		echo '<center>(This post contains affiliate links. <a href="https://gretchenlouise.com/disclosure/">Read my full disclosure</a>.)</center>';
	}
}

add_action('kadence_single_before_entry_content', 'gl_before_entry_disclosure', 5);

function gl_before_entry_disclosure(){
	
	if ( is_single($post) )  {
		echo '<center>(This post contains affiliate links. <a href="https://gretchenlouise.com/disclosure/">Read my full disclosure</a>.)</center>';
	}
}

/**
 * Adapted from Bill Erickson's Modified Date
 *
 * @link https://www.billerickson.net/display-last-updated-date-on-articles/
 *
 */
function post_modified_date() {
	$updated = get_the_modified_date( 'U' );
	$output .= get_the_modified_date( 'F j, Y' ) . '';
	return $output;
}
add_shortcode( 'post_modified_date', 'post_modified_date' );

add_filter('comment_form_defaults', 'set_my_comment_title');
function set_my_comment_title( $defaults ){
	$defaults['title_reply'] = __('Leave your message', 'kadence-comments');
	return $defaults;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

10 Comments

  1. Hi there,

    I currently have a byline underneath all my blog titles stating that the post was “published by ABC on a specified date”. I am looking for some coding that would enable me to add an additional byline so that I can say one of the following: “Fact checked by ABC veterinarian” or “Reviewed and approved by ABC veterinarian” and their respective qualifications.

    Do you have a code for this functionality, please? I’m using a Restored316 theme and Kadence Pro.

    Thanks.

  2. Hi! Restored316 referred me over to you to add disclosure text based on a tag. I see the code above but the plugin you recommended caused a fatal error on my site. Is there another plugin that would work with the tag code you’ve provided?

    1. Was it the Code Snippets plugin that caused a fatal error on your site? Did the error message give you any details? Do you know if you’d used Code Snippets before and there might have been an active snippet that would have triggered the fatal error instead?

      Code Snippets is widely used and is what Kadence recommends for adding codes like these. You might want to reach out to your hosting support and see if they can tell why Code Snippets caused an error.

      1. I chatted with BigScoots because the error actually didn’t allow me to access my site anymore and they had to fix it on their end. They said that Code Snippets was causing a plugin conflict but since my site was working fine before, I just don’t feel like weeding out which plugin CS was having an issue with and removing that plugin. I also tried the plugin Insert Code PHP Snippet, but upon adding the code, it never showed on the post. Perhaps I’ll need to hire a developer to add what I need. Thank you, though!

        1. How strange! I’m not sure I’ve ever seen that plugin cause an issue. Are you using a Kadence child theme? If so, you could try adding that code to your child theme’s functions.php, as well.

          1. I see that I have the ability to add script to the Header, Body, or Footer via Settings ->Insert Header & Footer. OR, I see that I can add custom CSS via Appearance -> Customize -> Additional CSS. Is one of these option the location for the disclosure code?