Support » Developing with WordPress » wp_customize changing $args (label, input_attrs, …) in child

  • I as a non-PHP affine code manipulator are looking to change values defined in the main theme trough a child theme – I suppose in the functions.php
    For example:

    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
    	'label'      => __( 'Header Color', 'mytheme' ),
    	'section'    => 'your_section_id',
    	'settings'   => 'your_setting_id',
    ) ) );

    How can I change the ‘label’ value in the child?

Viewing 4 replies - 1 through 4 (of 4 total)
  • For that particular code, you could delete the control and add it back with a different label. Or you could try to set it (must be done after it’s created) like:
    $wp_customize->get_control( 'link_color' )->label = 'new label'

    Or you could use a plugin like Say What to change text.

    Thanks Joy. Since I should leave the main theme code unchanged and I do not want this controlled by a plugin I tried the second method in the child functions.php
    Found and
    Probably because of chronology of creation (as you noted) it seems to not work:
    Warning: Creating default object from empty value in /wp-content/themes/child-theme/functions.php

    Yes, the child theme functions run, followed by the parent theme functions. So you need to adjust the priority on the add_action call to make sure the child action runs after the parent’s.

    Wow! Thank you again! I was now able to achieve the run after the parent by using (after googling for advise):

    add_action( 'customize_register', 'childtheme_customize_register', 20); 
    function childtheme_customize_register( $wp_customize ) {
    $wp_customize->get_control( 'link_color' )->label = 'new label';

    So far it seems to run fine…

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.