1

I'm creating my first WordPress Genesis child theme. I'm trying to use the get_theme_mod() function to return two values from two custom controls I created on the WordPress back end. In functions.php, I have this:

$wp_customize->add_setting(
    'gs_custom_theme_setting_background_image_1',
        array(
            'default' => '',
            'sanitize_callback' => 'gs_custom_theme_sanitize_bgi',
        )
);

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize, 'gs_custom_image_bg_setting_1', array(
            'label' =>  __( 'Background Image 1st', 'gs-custom-theme' ),
            'settings' => 'gs_custom_theme_setting_background_image_1',
            'section' => 'gs_custom_theme_front_section',
            'priority' => 20
        )
    )
);


$wp_customize->add_setting(
    'gs_custom_theme_setting_color_background_1',
        array(
            'default' => '#000000',
            'sanitize_callback' => 'sanitize_hex_color'
        )
);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize, 'gs_custom_theme_setting_color_background_1', array(
            'label' => __( 'Background Color 1', 'gs-custom-theme' ),
            'settings' => 'gs_custom_theme_setting_color_background_1',
            'section' => 'gs_custom_theme_front_section',
            'priority' => 15
        )
    )
);

This creates two custom settings and two custom controls using the Theme Customizaion API (one color selector and one image selector). All I want to do is echo the hex value for whatever color I have selected and the URL for whatever image I have selected on my front page using the following in front-page.php:

<?php echo get_theme_mod('gs_custom_theme_setting_color_background_1') ?>

<?php echo get_theme_mod('gs_custom_theme_setting_background_image_1') ?>

The color selector works perfectly fine and displays the hex value of whatever color I select as intended. However, when I try to use the image selector on the back end, not only does no image URL show up on my front page, but I get this error message. I've looked around here and WordPress.org and this seems to be an issue related to javascript, but I haven't added any javascript to my site and I don't have any active plugins.

Anyone have any idea where to begin looking for this mystery syntax error?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Ryan M.
  • 61
  • 5
  • Change the background image one to: And I have never used the same control id as the settings id, but that might be why that one works and the other does not. Your control id "gs_custom_theme_setting_color_background_1" is the same as the setting "gs_custom_theme_setting_color_background_1". Also, I would use either Kirki(https://aristath.github.io/kirki/) or https://github.com/devinsays/customizer-library -- saves a lot of pain. – Christina Feb 06 '17 at 14:44

0 Answers0