Last active
November 16, 2020 19:42
-
-
Save hellofromtonya/0d751af7320f68238204 to your computer and use it in GitHub Desktop.
Add After Entry Widget to All Post Types, including Custom Post Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* 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