5

From some reason my active_callback => 'is_front_page' is not working and therefore not showing up inside the customizer on the front-page. I have definitely set my front page to static and selected the home page in the reading settings. I don't know what's wrong with it.

I appreciate the help :)

Code:

functions.php

// Customizer
function themeE4K_customize_register( $wp_customize ) {
    // Add Settings
    $wp_customize->add_setting('slider_one', array(
        'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
        'transport'     => 'refresh',
    ));
    $wp_customize->add_setting('slider_two', array(
        'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
        'transport'     => 'refresh',
    ));

    // Add Section
    $wp_customize->add_section('slider_image', array(
        'title'           => __('Slider Images', 'e4k-theme'),
        'description'     => __('Slider Images for the Home Page of the E4K Theme'), 
        'priority'        => 10,
        'active_callback' => 'is_front_page',
    ));

    // Add Controls
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'slider_one_control', array(
        'label' => __('Slider Image #1', 'e4k-theme'),
        'section' => 'slider_image',
        'settings' => 'slider_one',
    )));
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'slider_two_control', array(
        'label' => __('Slider Image #2', 'e4k-theme'),
        'section' => 'slider_image',
        'settings' => 'slider_two',
    )));    

}
add_action('customize_register', 'themeE4K_customize_register');
5
  • try refreshing your permalinks Commented Feb 1, 2016 at 11:21
  • ??? I don't think the permalinks has anything to do with the Customizer active_callback function @GuruTom
    – Stephen
    Commented Feb 1, 2016 at 11:24
  • Do you have any Loops to do with this code? If I remember right the active_callback requires one? Commented Feb 1, 2016 at 11:42
  • As far as I know it doesn't require a loop for what I need - WordPress Customizer API I've copied some of the code from here about half way down the page there is a section on the active callback function by looking at this you will see when you enables the active callback for the front-page the Site Title hides it self if your not on the front-page
    – Stephen
    Commented Feb 1, 2016 at 11:48
  • I tried your code and it is working as expected. Commented Apr 17, 2016 at 17:34

1 Answer 1

2

I have copy-pasted your function into my dev install and your two controls show up in the customizer, both with a static front page and with a blog posts front page.

So something is messing with is_front_page in your install. If I were you I'd echo the conditions in function to see if something is wrong there. It could be a stupid database writing error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.