Can we add more than one control under a setting in WP theme customizer?

In wordpress theme customizer, we need to define a setting to add a control. My question is can we add more than one control under a setting?

If yes, how to access the values of those controls. In documentation i found that we can read values of settings. get_theme_mod( 'site_logo' ), but its not mentioned how to read value of controls.

If we can not add more then one control under one setting, what’s the benefit of having settigns?

I believe i have missed something somewhere, that describes how both settings and controls differentiate with each other.

Any help is appreciated!

2 Answers
2

I would say no, because a setting needs a unique ID, if you have two controls with the same ID, they will set the same name attribute to two different inputs in the controls and conflict so only one value will be saved.

Actually do not see much point in having them separated at all, you can’t really use one without the other in any meaningful way I can see, but maybe there is a use case for keeping them separate.

Instead if you wanted more control over a single setting you would need to create a custom control class with multiple UI inputs and javascript in it to help calculate a single setting value. But be sure to only use the setting name attribute on the actual element where the final value will be. Otherwise, better to just create another setting with it’s own control.

Leave a Comment