Customising the Customiser


Hey Mike,

Here is the code snippet to add your secondary logo and footer fields using a loop:

add_action( 'customize_register', 'example_wp_customize_options' );

function example_wp_customize_options() {

  // Secondary logo image.
  $fields = array(
        array(
            'id' => 'example_logo_image_secondary',
            'label' => 'Secondary Logo Image',
            'type' => 'WP_Customize_Image_Control',
            'transport' => 'refresh'
        )
    );

    beans_register_wp_customize_options( $fields, 'title_tagline' );

    // Footer fields.
  $total = 4;
 $fields = array();

    for ( $i = 1; $i <= $total; $i++ ) {

        $fields[] = array(
            'id' => "example_footer_logo_{$i}",
            'label' => "Logo Image {$i}",
            'type' => 'WP_Customize_Image_Control',
            'transport' => 'refresh',
        );

    }

    beans_register_wp_customize_options( $fields, 'section_id', array( 'title' => 'Footer Logos' ) );

}

Note that I prefixed the function and fields id with example_. All your functions and fields id in your project should be prefixed with a unique prefix of your choice. I would not advise to just have footer_logos as it may create conflicts in the future (for example if WordPress adds a function called footer_logos a the future version).

Regarding your secondary logo field, see that we just used the same section id title_tagline so that the field is added to that section instead of creating a new section like we do for the footer logos πŸ˜‰

PS: never make changes in Beans Core files as it would be overwritten when you update. I think you just temporarly added your secondary logo field so make sure you remove it now that you added it via your child theme.

Thanks,


Thanks Thierry, some valuable info there! πŸ™‚


Hey Thierry,

Am i correct in saying I can add this to the example_wp_customize_options function above...

global $wp_customize;

$wp_customize->remove_section('colors');

...to remove the Color section in the WP Customizer? It works, just want to know if it's the best way to do it within the Beans framework.

Cheers,

m


Hey Mike, yes it is fine to do so πŸ™‚

Write a reply

Login or register to write a reply, it's free!