Add Link In Genesis Entry Meta

The 1st code snippet in this tutorial creates a new shortcode which enables you to add a link to the entry meta in the entry footer. In this case, it adds a link for a disclosure policy.

Once you create the shortcode, you can then add it using the genesis_post_meta filter hook which adds it to the post meta in the entry footer. You can add the shortcode before or after the categories and tags.

Add the following code to your child themes functions file.

add_shortcode( 'disclosure', 'genesis_disclosure_link_shortcode' );

function genesis_disclosure_link_shortcode( $atts ) {

    $link = sprintf( '<a href="%s">%s</a>', esc_url( 'http://example.com/' ), 'Disclosure Policy' );

	$defaults = array(
		'after'  => '',
		'before' => __( 'FTC Compliance: ', 'genesis' ),
		'link'   => $link,
	);

	$atts = shortcode_atts( $defaults, $atts, 'disclosure' );

	$output = sprintf( '<span %s>', genesis_attr( 'disclosure-policy' ) ) . $atts['before'] . $atts['link'] . $atts['after'] . '</span>';

	return $output;

}

Also add the following code:

If you want to add a link in the entry meta ( post info ) in the entry header on single posts, use the following code:

Here’s one example:

You could also add it using the shortcode with the genesis_post_info filter function.

Related Tutorials

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.