Visual Composer custom markup for custom shortcode (vc_map)

不羁的心 提交于 2020-02-20 10:51:06

问题


Trying to get custom_markup to work with the Visual Composer builder for WordPress.

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.

Here's some documentation for the vc_map function https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524332

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();

Which currently looks like --> https://dl.dropboxusercontent.com/u/11204765/SS/mac/Screen%20Shot%202016-05-02%20at%2012.52.56.png

In the example below I've tried to set custom_markup to test

which results in 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.

I've looked almost everywhere for a solution, including browsing through other Visual Composer plugins to see how they've accomplished this.

Any help would be greatly appreciated!


回答1:


What are you trying to accomplish exactly ? From the visual composer core code this is the custom markup for the tabs

'custom_markup' => '
<div class="wpb_tabs_holder wpb_holder vc_container_for_children">
<ul class="tabs_controls">
</ul>
%content%
</div>',

So maybe something like %customattr% will get your desired result?




回答2:


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' ),
            ),

        )

and if you want hide a section in the backend just remove the 'holder' line



来源:https://stackoverflow.com/questions/36980890/visual-composer-custom-markup-for-custom-shortcode-vc-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!