Search code examples
wordpressvisual-composer

In Wordpress Visual Composer, is it possible to set default values for the fields under Select Custom Fields?


Specifically I'd like to give every new post a particular sidebar by default. Seems like setting default values should be possible, but I can't see where in the interface and a Google turned up nothing, so any advice appreciated. Thanks!


Solution

  • You can do this by using the "value" property of the parameter array(s) for vc_map() or vc_add_parameter(). Documentation is here... see the description of the value property.

    An example would be:

    function vc_myshortcode(){
        vc_map({
        'name' => 'My Shortcode',
        'base' => "myshortcode",
        'params' => array(
            array(
                'type'=>'textfield',
                'holder'=>'div',
                'param_name'=>'color',
                'value'=>'#333333'
            )
        )
    })}
    add_action( 'vc_before_init', 'vc_myshortcode' );
    

    So the default value for the color parameter would then be set to #333333