2

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' );
  • why use return $value; in parent theme? – Jignesh Patel Jan 3 '18 at 11:53
  • I don't know @patel-jignesh. There are more options on the customizer.php of the parent theme, like: /* Remove Colors & Header Image Customize */ $wp_customize->remove_section('colors'); $wp_customize->remove_section('header_image'); I just placed the relevant code I want to change, do I need to add all the options of the customizer.php? – Duarte Nunes Jan 3 '18 at 11:58
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',
     ))); 
}
  • It worked. Thanks for pointing me in the right direction @patel-jignesh. – Duarte Nunes Jan 3 '18 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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