自定义短代码 (vc_map) 的 Visual Composer 自定义标记 [英] Visual Composer custom markup for custom shortcode (vc_map)
问题描述
尝试让 custom_markup 与适用于 WordPress 的 Visual Composer 构建器一起使用.
Trying to get custom_markup to work with the Visual Composer builder for WordPress.
找到 Visual Composer 更改自定义简码模板 以及 Visual Composer 自定义简码模板 - custom_markup 显示用户输入 但没有其中有一个答案.
Found Visual Composer change custom shortcode template and also Visual Composer custom shortcode template - custom_markup display user input but none of them has an answer.
以下是 vc_map 函数的一些文档https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524332
Here's some documentation for the vc_map function https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524332
这是我正在使用的短代码,一切正常,只是在后端 ui 中看起来很糟糕
Here's my shortcode that I'm using, everything works perfectly, it just looks horrible in the backend ui
vc_map( array(
"name" => "example",
"base" => "adwise_vc_example",
"class" => "",
"category" => "Plugin name",
"icon" => "awm_vc_icon",
"custom_markup" => load_template( ADWISE_VC_DIR . '/vc_templates/adwise_example.php', false),
"params" => array();
目前看起来像--> https://dl.dropboxusercontent.com/u/11204765/SS/mac/Screen%20Shot%202016-05-02%20at%2012.52.56.png
在下面的示例中,我尝试将 custom_markup 设置为 test
In the example below I've tried to set custom_markup to test
导致 https://dl.dropboxusercontent.com/u/11204765/SS/mac/Screen%20Shot%202016-05-02%20at%2012.45.55.png
vc_map( array(
"name" => "example",
"base" => "adwise_vc_example",
"class" => "",
"category" => "Plugin name",
"icon" => "awm_vc_icon",
"custom_markup" => "test",
"params" => array();
我的主要/主要问题是我不知道如何获取每个短代码的每个属性的值以显示在模板文件中.
My primary/main problem is that I don't know how to get the values of each attribute for each shortcode to display in the template file.
我几乎到处寻找解决方案,包括浏览其他 Visual Composer 插件以了解它们是如何实现的.
I've looked almost everywhere for a solution, including browsing through other Visual Composer plugins to see how they've accomplished this.
任何帮助将不胜感激!
推荐答案
只需在 'params' 中添加一个带有短代码属性的数组
just add an array with the shortcode attributes in 'params'
'params' => array(
array(
'type' => 'textfield',
'holder' => 'div',
'class' => '',
'heading' => __( 'Title' ),
'param_name' => 'title',
'value' => __( 'Titre' ),
'description' => __( 'Title' ),
),
array(
'type' => 'textarea',
'holder' => 'div',
'class' => '',
'heading' => __( 'Description' ),
'param_name' => 'desc',
'value' => __( 'description' ),
'description' => __( 'Description' ),
),
array(
'type' => 'attach_image',
'holder' => 'img',
'class' => '',
'heading' => __( 'Image' ),
'param_name' => 'img_url',
'value' => __( '' ),
'description' => __( 'Image' ),
),
)
如果你想在后端隐藏一个部分,只需删除'holder'行
and if you want hide a section in the backend just remove the 'holder' line
这篇关于自定义短代码 (vc_map) 的 Visual Composer 自定义标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!