vc_add_param()

⌘K
  1. Home
  2. Docs
  3. Inner API
  4. vc_add_param()

vc_add_param()

SINCE 4.3

To add new parameter to existing content element you can use vc_add_param() function. List of available parameters.

<?php vc_add_param( $shortcode, $attributes ); ?>

Params

Param name
Type
Description
$shortcodeStringShortcode base. For [my_shortcode] shortcode base is my_shortcode. For default “Message box” element, base is “vc_message”
$attributesArrayArray should be defined according to vc_map() available options.

Example

How to add new attribute to the default “Message box” content element:

<?php
$attributes = array(
  'type' => 'dropdown',
  'heading' => "Style",
  'param_name' => 'style',
  'value' => array( "one", "two", "three" ),
  'description' => __( "New style attribute", "my-text-domain" )
);
vc_add_param( 'vc_message', $attributes ); // Note: 'vc_message' was used as a base for "Message box" element
?>

Code explanation:

  1. First we create array which “describes” new attribute that should be added to “Message box” element. Note: during the initial vc_map() function call “vc_message” was used as a base attribute, base is required to properly “target” function call
  2. Then we call vc_add_param() function with new attribute and base
Was this article helpful to you? No 2 Yes

How can we help?