Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiemitchell/5ee59a1140c24ac1db5c9d11d14493c1 to your computer and use it in GitHub Desktop.
Save jamiemitchell/5ee59a1140c24ac1db5c9d11d14493c1 to your computer and use it in GitHub Desktop.
Add Customizer Control for Adding Featured Image automatically to Posts/Pages - http://wpbeaches.com/add-featured-image-top-page-genesis/
<?php //<= dont add me in
add_action( 'customize_register', 'themeprefix_customizer_featured_image' );
function themeprefix_customizer_featured_image() {
global $wp_customize;
// Add featured image section to the Customizer
$wp_customize->add_section(
'themeprefix_single_image_section',
array(
'title' => __( 'Post and Page Images', 'themeprefix' ),
'description' => __( 'Choose if you would like to display the featured image above the content on single posts and pages.', 'themeprefix' ),
'priority' => 200, // puts the customizer section lower down
)
);
// Add featured image setting to the Customizer
$wp_customize->add_setting(
'themeprefix_single_image_setting',
array(
'default' => true, // set the option as enabled by default
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'themeprefix_single_image_setting',
array(
'section' => 'themeprefix_single_image_section',
'settings' => 'themeprefix_single_image_setting',
'label' => __( 'Show featured image on posts and pages?', 'themeprefix' ),
'type' => 'checkbox'
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment