{"id":356,"date":"2014-03-16T23:09:43","date_gmt":"2014-03-16T21:09:43","guid":{"rendered":"https:\/\/urosevic.net\/wordpress\/?p=356"},"modified":"2026-03-10T16:51:49","modified_gmt":"2026-03-10T15:51:49","slug":"dropdown-defaults-visual-composer","status":"publish","type":"post","link":"https:\/\/urosevic.net\/wordpress\/tips\/dropdown-defaults-visual-composer\/","title":{"rendered":"Dropdown attribute with default value in WPBakery Page Builder"},"content":{"rendered":"\n<p>I&#8217;m currently implementing support for WPBakery Page Builder to my plugins and went to not well-documented dropdown attribute parameters.<\/p>\n\n\n\n<p>So, when we have an array of available values (no matter if the array contains <code>key=>value<\/code>, values only or it&#8217;s mixed), and we also have a default value for that parameter set in plugin options (for example), it is possible to pre-select that default value in the dropdown list.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Even you will not find a clear explanation about how to do that in the <a href=\"https:\/\/kb.wpbakery.com\/docs\/inner-api\/vc_map\/#vc_map()-Availabletypevalues\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"WPBakery Visual Composer vc_map() available type values\">WPBakery Knowledge Base<\/a>\u00a0for the <code>vc_map()<\/code> function, if you dig plugin files, or analyse other plugins, you&#8217;ll find it for sure \ud83d\ude42<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Example parameters for the dropdown attribute<\/h2>\n\n\n\n<p>So, here we go. The magic parameter we need here is std and should contain the default value (key for multidimensional array). Here is the demo code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nvc_map( array(\n  'name'     =&gt; __('Foo Bar'),\n  'base'     =&gt; 'foo_bar',\n  'category' =&gt; __('Content'),\n  'params'   =&gt; array(\n    array(\n      'type'        =&gt; 'dropdown',\n      'heading'     =&gt; __('Foo'),\n      'param_name'  =&gt; 'foo',\n      'admin_label' =&gt; true,\n      'value'       =&gt; array(\n        'one'   =&gt; 'First Option',\n        'two'   =&gt; 'Second Option',\n        'three' =&gt; 'Third Option',\n        'four'  =&gt; 'Fourth Option'\n      ),\n      'std'         =&gt; 'two', \/\/ Your default value\n      'description' =&gt; __('The description')\n      )\n    )\n  )\n);\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to preselect value in dropdown list when custom WPBakery Page Builder block is added to page\/post layout, based on default plugin settings.<\/p>\n","protected":false},"author":1,"featured_media":381,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[7,8,9,10,5,6],"class_list":["post-356","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","tag-dropdown","tag-howto","tag-php","tag-wordpress","tag-wpbakery","tag-wpbakery-page-builder"],"_links":{"self":[{"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/posts\/356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/comments?post=356"}],"version-history":[{"count":14,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":3025,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/posts\/356\/revisions\/3025"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/media\/381"}],"wp:attachment":[{"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/media?parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/categories?post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/urosevic.net\/wordpress\/wp-json\/wp\/v2\/tags?post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}