不知道,如何在Visual Composer中为“设计选项”组添加新选项。在我的情况下,我需要添加容器元素宽度。
提前致谢
答案 0 :(得分:0)
我不确定您是否可以为所有元素全局设置自定义选项,但如果您要构建自定义元素,则可以执行以下操作:
vc_map( array(
"name" => __( "Custom Element Name", "my-text-domain" ),
"base" => "custom_element",
"params" => array(
array(
'type' => 'textfield',
'heading' => __( 'Container Element Width', 'my-text-domain' ),
'param_name' => 'container_element_width',
'group' => __( 'Design options', 'my-text-domain' ),
),
),
) );
然后您可以在输出中使用该参数。
答案 1 :(得分:0)
您可以使用vc_add_param():
https://wpbakery.atlassian.net/wiki/spaces/VC/pages/524335/vc+add+param
并将该组确定为“设计选项”,例如:
$attributes = array(
'type' => 'textfield',
'heading' => __( 'My Field', 'lang_domain' ),
'description' => __( 'Description here."', 'lang_domain' ),
'param_name' => 'my_field',
'group' => __( 'Design Options', 'lang_domain' ),
'admin_label' => true,
);
您可以为下面的任何元素添加以下行:
vc_add_param( 'vc_element_1', $attributes );
vc_add_param( 'vc_element_2', $attributes );
etc...
然后从以下文件夹中复制要添加字段的元素:
js_composer/include/templates/shortcodes/vc_element_1.php
etc...
并将其放在主题或插件的文件夹中。您可以随意编辑这些文件,并将新字段添加为变量,也可以编写内联css等:
echo '<div style="my_field: '.$my_field.';">';
或
echo '<div style="my_field: '.$atts['my_field"].';">';
然后你需要设置这个文件夹让VC知道并用vc_set_shortcodes_templates_dir()读取这个短代码:
https://wpbakery.atlassian.net/wiki/spaces/VC/pages/524294/vc+set+shortcodes+templates+dir