Using the child theme functions.php to change the customizer.php on parent theme

I’m trying to add a second logo option to the customizer.php of the parent theme using the functions.php from the child theme. But, I’m getting a 500 Internal Server Error. What am I doing wrong?

This is the code of the customizer.php file inside the folder “extend” on the parent theme.

function j007_customize_register( $wp_customize ) {
/* Logo */

$wp_customize->add_setting( 'logo', array(
  'type' => 'theme_mod', // or 'option'
  'capability' => 'edit_theme_options',
  'theme_supports' => '', // Rarely needed.
  'default' => '',
  'transport' => 'refresh', // or postMessage
  'sanitize_callback' => 'j007_fun_sanitize_callback' // Get function name 

) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array(
    'label'    => esc_html__( 'Logo', 'em4u' ),
    'section'  => 'header_section',
    'settings' => 'logo'
)));

}

function j007_fun_sanitize_callback($value){
return $value;
}

add_action( 'customize_register', 'j007_customize_register' );

And this is the code I’m using on the functions.php of the child theme

// Add alternative logo
function j007_customize_register( $wp_customize )
{
$wp_customize->add_setting( 'logo_alt', array(
    'type' => 'theme_mod', // or 'option'
    'capability' => 'edit_theme_options',
    'theme_supports' => '', // Rarely needed.
    'default' => '',
    'transport' => 'refresh', // or postMessage
    'sanitize_callback' => 'j007_fun_sanitize_callback' // Get function name 

  ) );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'logo_alt',
        array(
            'label' => esc_html__( 'Logo', 'j007' ),
            'section'  => 'header_section',
            'settings' => 'logo_alt'
        )
    )
);
}
add_action( 'customize_register', 'j007_customize_register' );

1 Answer
1

Put this code in function.php. create custom section in customizer for logo :

<?php
add_action('customize_register', 'theme_footer_customizer');
function theme_footer_customizer($wp_customize){
    //adding section in wordpress customizer   
    $wp_customize->add_section('footer_settings_section', array(
      'title'          => 'Footer Text Section'
    ));
    //adding setting for footer logo
    $wp_customize->add_setting('footer_logo');
    $wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize,'footer_logo',array(
     'label'      => 'Footer Logo',
     'section'    => 'footer_settings_section',
     'settings'   => 'footer_logo',
     ))); 
}

Leave a Comment