0

As here is a ticket about input_attrs class not working for some controls .

I want to know if I can wrap some wordpress customize control inside a div ?

Can I do something like

$wp_customize->add_control( $this->slug . '_style[heading_text_decoration]', array(
            'label'    => __('Text Decoration'),
            'type'     => 'checkbox',
            'section' => $this->slug . '_text_style',
            'priority' => 16,
            'input_attrs' => array(
                'before' => '<div class="my-wrap">',
                'class' => 'section-style-all-heading',
                'after' => '</div>'
            ),
        ) );

or

$wp_customize->add_control( $this->slug . '_style[heading_text_decoration]', array(
            'label'    => __('Text Decoration'),
            'type'     => 'checkbox',
            'section' => $this->slug . '_text_style',
            'priority' => 16,
            'input_attrs' => array(
                'wrap' => '<div class="my-wrap"></div>',
                'class' => 'section-style-all-heading',
            ),
        ) );

or any other way to do it ?

  • Its the div really necessary? – David Lee Feb 15 '17 at 15:09
  • @DavidLee I want to separate the controls and want to show and hide using javascript. – Prafulla Kumar Sahu Feb 16 '17 at 7:39
  • you dont have access to the files that add the controls? separate with CSS? – David Lee Feb 16 '17 at 16:16
  • @DavidLee consider a section having 15 controls now I want to organize those by 3 groups and only one group will visible that will be chosen by select box now, if I can not add class or wrap, how I will separate them ? – Prafulla Kumar Sahu Feb 16 '17 at 19:28
  • that can be done in 2 ways and you dont need input_attrs since its at the control level, this is a entire new question. – David Lee Feb 16 '17 at 20:07
0

As the ticket says, input_attrs is not working for:

checkboxes, textareas, and other non-fallthrough cases

to have the wrapper you would have to create your own custom control and add the div in the render part, or go the hackish way with JavaScript.

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.