I am creating a child theme using the storefront as a parent theme so far I am doing well, I am trying to create a website where I can change the basic aspects of the style of the website like background-color, custom text in wp-admin/customize.php.
I know I can add more options using customize_register , but the storefront theme has its own action hook for that, in fact I already added my own action hook to enable more options see below
as you can see the problem is that it creates another "footer" option, is there any way to overwrite or insert custom options, within the existing "footer" option of the parent theme?
here the code im using to insert options
function footer_customize_register( $custom_vars ) {
$custom_vars ->add_section(
'layout_section',
array(
'title' => __( 'Footer', 'pre' ),
'capability' => 'edit_theme_options',
'description' => __( 'Allows you to edit your theme layout.', 'pre' ),
'priority' => 25,
)
);
$custom_vars -> add_setting('pre_layout_options[address_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '000 7th St NW',
));
$custom_vars -> add_control('pre_layout_options[address_text]', array(
'label' => 'adress',
'section' => 'layout_section',
'type' => 'text',
));
$custom_vars -> add_setting('pre_layout_options[phone_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '01234-567',
));
$custom_vars -> add_control('pre_layout_options[phone_text]', array(
'label' => 'ZIP code',
'section' => 'layout_section',
'type' => 'text',
));
$custom_vars -> add_setting('pre_layout_options[VAT]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '00.000.000/0000-00',
));
$custom_vars -> add_control('pre_layout_options[VAT]', array(
'label' => 'VAT number',
'section' => 'layout_section',
'type' => 'text',
));
$custom_vars -> add_setting('pre_layout_options[Location]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => 'Centro',
));
$custom_vars -> add_control('pre_layout_options[Location]', array(
'label' => 'Location',
'section' => 'layout_section',
'type' => 'text',
));
}
add_action('customize_register', 'footer_customize_register');
the source code is from here
in section
you need to add storefront_footer
and add priority
to change position. check below code.
function footer_customize_register( $custom_vars ) {
$custom_vars -> add_setting('pre_layout_options[address_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '000 7th St NW',
));
$custom_vars -> add_control('pre_layout_options[address_text]', array(
'label' => 'adress',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 50,
));
$custom_vars -> add_setting('pre_layout_options[phone_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '01234-567',
));
$custom_vars -> add_control('pre_layout_options[phone_text]', array(
'label' => 'ZIP code',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 60,
));
$custom_vars -> add_setting('pre_layout_options[VAT]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '00.000.000/0000-00',
));
$custom_vars -> add_control('pre_layout_options[VAT]', array(
'label' => 'VAT number',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 70,
));
$custom_vars -> add_setting('pre_layout_options[Location]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => 'Centro',
));
$custom_vars -> add_control('pre_layout_options[Location]', array(
'label' => 'Location',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 80,
));
}
add_action('customize_register', 'footer_customize_register');
Tested and works.