【发布时间】:2018-01-29 14:27:22
【问题描述】:
我想在 Visual Composer 中创建自定义元素,它将在 vc_single_image 中添加 2 个图像 例如:
<div class="vc_single_image-wrapper vc_box_border_grey">
<img src="img/macbook.png" class="vc_single_image-img attachment-full">
<img src="img/tmp/mac-ins.png" class="vc_single_image-img attachment-full template-mac--ins">
</div>
在我的functions.php中,我执行以下操作:
function vc_before_init_actions() {
if( function_exists('vc_set_shortcodes_templates_dir') ){
vc_set_shortcodes_templates_dir( get_template_directory() . '/vc-elements' );
}
}
add_action( 'vc_after_init', 'vc_after_init_actions' );
function vc_after_init_actions() {
$vc_single_image_new_params = array(
array(
'type' => 'attach_image',
'heading' => __( 'Second Image', 'js_composer' ),
'param_name' => 'secondImage',
'value' => '',
'description' => __( 'If you need use 2 image inside one "single image"', 'js_composer' ),
'dependency' => array(
'element' => 'source',
'value' => 'media_library',
),
'admin_label' => true,
'group' => 'Addititonal',
),
);
vc_add_params( 'vc_single_image', $vc_single_image_new_params );
}
我已经将文件形式 js_composer/include/shortcodesvc_single_images 复制到 MyTheme/vc-elements/ 之后我更改了该文件的 html 结构(添加新变量“secondImage”)。
问题:当我在 VP 中创建此元素并添加新图像(1 个来自原始面板,其他来自我的自定义)时,我尝试更新页面,好吧,更新后什么都没有保存。
怎么了??
【问题讨论】:
标签: wordpress shortcode visual-composer