
In a recent WordPress project i worked on, i needed to have an input field and a select dropdown close to each other. Below is a screenshot of what i was looking to achieve. I had two ideas of how i would pull this off but none of them quite frankly pleased me. Here are the ideas and why i used neither.
* Create customize setting and control for the input and select fields since core already has support for input and select fields.
Going this route would have meant not being able add inline style to set the width property of the select dropdown to auto so it doesn’t have an 100% value added by Customizer to virtually every of its core controls.
Adding inline style is possible for input fields using the input_attrs argument.
* Create custom controls for the input and select fields to allow for the flexibility i craved for.
Going this route would have meant writing lots of code (register the customize settings and coding the PHP classes for the custom control for each fields) to achieve something this simple.
Reading the WordPress Customizer documentation, one would think that the standard is: for every customize settings, there can only be one corresponding customize control.
Controls
Source: https://managewp.org/articles/14623/wordpress-customizer-using-multiple-customize-settings-in-single-control
source https://williechiu40.wordpress.com/2017/03/16/wordpress-customizer-using-multiple-customize-settings-in-single-control/
No comments:
Post a Comment