Skip to content

Instantly share code, notes, and snippets.

@mahafuz
Created December 12, 2017 11:50
Show Gist options
  • Save mahafuz/9aa69e666f91e09f51c64bdf29dfe0d8 to your computer and use it in GitHub Desktop.
Save mahafuz/9aa69e666f91e09f51c64bdf29dfe0d8 to your computer and use it in GitHub Desktop.
Dropdown attribute with default value in WPBakery Visual Composer
<?php
/**
* Visual Composer DropDown Item Example in Right Way
* Dropdown attribute with default value in WPBakery Visual Composer
*
* @package VC_Dropdown
* @author Mahfuz <asrmahfuz8@gmail.com>
*/
vc_map(array(
"name" => __( "VC Dropdown", 'textdomain' ),
"description" => __( "VC Dropdown items example in right way!!!", 'textdomain' ),
"base" => 'base_name',
"controls" => "full",
"category" => __( 'category_name', 'textdomain' ),
"params" => array(
array(
'type' => 'dropdown',
'heading' => __( 'Dropdown Items', 'textdomain' ),
'value' => array(
__( 'Item One', 'textdomain' ) => '1',
__( 'Item Two', 'textdomain' ) => '2',
__( 'Item Three', 'textdomain' ) => '3',
__( 'Item Four', 'textdomain' ) => '4'
),
'description' => __( 'Upload member photo.', 'textdomain' ),
'param_name' => 'dropdown_items'
)
)
)
);
@Luckyfella73
Copy link

It's a few years ago I wrote that bit of code.. but at time of writing it worked. Here you can read a tutorial about that topic with several comments of other people the code worked for as well:

https://urosevic.net/wordpress/tips/dropdown-defaults-visual-composer/

If I remember right that parameter was not documented years ago either but implemented nevertheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment