Custom theme customizer options don't seem to show on homepage

I am quite new to php and I’m creating a section in theme customiser (in a custom WordPress theme) to change the top banner image. All appears to work well - the options show in the customizer, I can select and upload images, and save the changes. But when refreshing the main page, all I see is what is in index.php outside of the php tags that are supposed to retrieve the images / text etc. Below is the code in the theme-customizer.php file (I’ve exluded the sections showing code for adding text as if I can get the image to show the rest should follow):

[php]add_action(‘customize_register’, ‘k1_customize_register’);
function k1_customize_register($wp_customize) {
// Logo
$wp_customize->add_section(‘k1_logo’, array(
‘title’ => __(‘Logo’, ‘k1-framework’),
‘description’ => __(‘Allows you to upload a custom logo.’, ‘k1-framework’),
‘priority’ => 35
));

$wp_customize->add_setting('k1_custom_settings[logo]', array(
    'default' => IMAGES . '/logo.png',
    'type' => 'option'
));

$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo', array(
    'label' => __('Upload your Logo', 'k1-framework'),
    'section' => 'k1_logo',
    'settings' => 'k1_custom_settings[logo]'
)));

// Top Banner Image
$wp_customize->add_section('k1_banner', array(
    'title' => __('K1 Top Banner', 'k1-framework'),
    'description' => __('Allows you to upload a banner image to display underneath the main navigation.', 'k1-framework'),
    'priority' => 36
));

// Add setting for checkbox
$wp_customize->add_setting('k1_custom_settings[display_k1_banner]', array(
    'default' => 0,
    'type' => 'option'
));

// Add control for checkbox
$wp_customize->add_control('k1_custom_settings[display_k1_banner]', array(
    'label' => __('Display the Top Banner Image?', 'k1-framework'),
    'section' => 'k1_banner',
    'settings' => 'k1_custom_settings[display_k1_banner]',
    'type' => 'checkbox'
));

// Add setting for top banner image
$wp_customize->add_setting('k1_custom_settings[k1_banner]', array(
    'default' => 'http://lorempixel.com/1200/300',
    'type' => 'option'
));

// Add control for top banner image
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'k1_banner', array(
    'label' => __('Upload the Top Banner Image', 'k1-framework'),
    'section' => 'k1_banner',
    'settings' => 'k1_custom_settings[k1_banner]',

)));[/php]

And in index.php where the php code is called:

[php] <?php
// Get options
$options = get_option(‘k1_custom_settings’);
?>

            <?php if($options['display_k1_banner'] != '') : ?>  

            <div class="top-banner-inner">

            <img src="<?php print $options['k1_banner']; ?>" alt="Banner image" />
                <h1><?php echo $options['k1_banner_heading']; ?></h1>
                    <p><?php echo $options['k1_banner_desc']; ?></p>
                    <a class="button" href="<?php echo $options['k1_banner_link']; ?>"><em>More</em></a>

            </div> <!-- end top-banner-inner -->

                <?php endif; ?> 

        </div> <!-- end top-banner -->

    </div> <!-- end row -->

</div> <!-- end container -->[/php]

The original html where the banner was to be is:

[code]

    <div class="row">

        <div class="col-lg-12 top-banner">

            <div class="top-banner-inner">

            <img src="http://lorempixel.com/1200/300" alt="Banner image" />
                <h1>Heading text</h1>
                    <p>Lorem ipsum dolor sit amet</p>
                    <a class="button" href=""><em>More</em></a>



            </div> <!-- end top-banner-inner -->


        </div> <!-- end top-banner -->

    </div> <!-- end row -->

</div> <!-- end container -->[/code]

If anyone has any ideas on how to get this to work I would really appreciate it.

Did you solve this one yet? How did you debug it so far?

Are the images showing as image placement squares or not showing at all? Have you viewed-source of the
final output page to see if the images are in the HTML code and just not pointing to the correct folder? There
is a lot of things that could be wrong here. Let us know where you stand on the debugging of this.

Sponsor our Newsletter | Privacy Policy | Terms of Service