Dropdown attribute with default value in WPBakery Visual Composer

Learn how to preselect value in dropdown list when custom Visual Composer block is added to page/post layout, based on default plugin settings.

I’m currently implementing support for Visual Composer to my plugins, and went to not well documented dropdown attribute parameters.

So, when we have array of available values (no matter if array contains key=>value, values only or it’s mixed), and we also have default value for that parameter set in plugin options (for example), it is possible to pre-select that default value in dropdown list.

Even you will not find clear explanation about how to do that in WPBakery Knowledge base for vc_map() functionality, if you dig plugin files, or analyse other plugins, you’ll find it for sure 🙂

Example parameters for dropdown attribute

So, here we go. Magic parameter that we need here is std, and should contain default value (key for multidimensional array). Here is demo code: