Add this to functions.php
// ========================================================================= // CUSTOMIZER COVER // ========================================================================= function genesis_cover_customize_register( $wp_customize ) { // Add Settings $wp_customize->add_setting('customizer_setting_cover_image', array( 'transport' => 'refresh', 'height' => 325, )); // Add Section $wp_customize->add_section('cover_section', array( 'title' => __('Cover image', 'name-theme'), 'priority' => 70, )); // Add Controls $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'customizer_setting_cover_image', array( 'label' => __('Add cover image', 'name-theme'), 'section' => 'cover_section', 'settings' => 'customizer_setting_cover_image', ))); } add_action('customize_register', 'genesis_cover_customize_register');
Call
<img src="<?php echo esc_url( get_theme_mod( 'customizer_setting_cover_image' ) ); ?>" alt="Cover image">
Hook cover v1
// ========================================================================= // COVER // ========================================================================= add_action('genesis_before_content', 'cover'); function cover(){ if ( is_front_page() ){ echo '<img class="cover" src="'.esc_url( get_theme_mod( 'customizer_setting_cover_image' ) ).'" alt="Cover Image">'; } }
Hook cover v2
// ========================================================================= // COVER // ========================================================================= add_action('genesis_after_header', 'add_cover'); function add_cover(){ if( is_front_page() ){ include('inc/cover.php'); } } include('functions/add-cover-to-customizer.php');
Leave a Reply