Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Last active November 16, 2020 19:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellofromtonya/0d751af7320f68238204 to your computer and use it in GitHub Desktop.
Save hellofromtonya/0d751af7320f68238204 to your computer and use it in GitHub Desktop.
Add After Entry Widget to All Post Types, including Custom Post Types
//* Make sure your child theme has this line in the functions.php file
add_theme_support('genesis-after-entry-widget-area');
add_action( 'genesis_after_entry', 'lunarwp_add_after_entry_widget_area' );
/**
* Display after-entry widget area on the genesis_after_entry action hook.
*
* @since 1.0.0
*
* @uses genesis_widget_area() Output widget area.
*/
function lunarwp_add_after_entry_widget_area()
{
//* Bail out if the theme does not support after entry widget
if ( ! current_theme_supports( 'genesis-after-entry-widget-area')) return;
//* Get all the custom post types
$custom_post_types = get_post_types(array('_builtin' => false), 'names');
//* Bail out if this page is not one of the custom post types
if ( ! in_array(get_post_type(get_the_ID()), $custom_post_types)) return;
genesis_widget_area( 'after-entry', array(
'before' => '<div class="after-entry widget-area">',
'after' => '</div>',
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment