I am building controls (a) that are generated using a value from a control (b) in another section.
However, unless the full customize page is refreshed then then there doesn’t seem to be a way to update (a) when (b) changes. Is there a solution for this use-case?
I am building controls (a) that are generated using a value from a control (b) in another section.
However, unless the full customize page is refreshed then then there doesn’t seem to be a way to update (a) when (b) changes. Is there a solution for this use-case?
Share Improve this question asked Nov 9, 2018 at 16:49 Danny CooperDanny Cooper 3302 silver badges12 bronze badges 1- very similar to my question: wordpress.stackexchange/questions/293902/… – Joy Reynolds Commented Jan 10, 2019 at 21:43
1 Answer
Reset to default 1It depends what "update" means.
If you want just to hide or show the control, (like how WordPress sidebar area is appearing and disappearing when the sidebar is present or not) then you can use the active_callback
parameter of the customize_control like this.
Edit: Also, active_callback
works on sections and panels too.
If you want the change the control's HTML structure, or text or anything else, then it requires advanced javascript knowledge, because you need to trigger javascript events from the previewer and catch them on the panel. This example comment should be enough for this case.