0

I just created a nested shortcode with vc_map for a wordpress website.

It works pretty well and is really simple.

My parent shortcode is "simple_table" and my chlidren shortcode are "simple_table_row".

[simple_table param="foo"]
   [simple_tablerow param="another_foo"]
   [simple_tablerow param="another_foo"]
   [simple_tablerow param="another_foo"]
[/simple_table]

I can add my shortcode in the root of a page or in row.

However I am unable to add inside an another container like tabs, tour, accordion or Pageable Container. My nested shortcode doesn't appear in the list of elements. I already created several simples shortcodes which work properly in these specific cases.

Here are my vc_map :

vc_map( array(
    "name" => "Simple_table",
    "description" => "Simple_table",
    "base" => "simple_table",
    "class" => "simple_table",
    "content_element" => true,
    "is_container" => true,
    'as_parent' => array('only' => 'simple_tablerow'),
    "show_settings_on_create" => true,
    "icon" => "simple_table_icon", 
    "category" => __('Content', 'js_composer'),
    "js_view" => 'VcColumnView',
    "params" => array(
                    array(
                        'type' => 'param_group',
                        'value' => '',
                        'param_name' => 'cols',
                        "heading" => "Cols",
                        'params' => array(
                            array(
                                'type' => 'textfield',
                                "holder" => "div",
                                'value' => '',
                                'heading' => 'Data',
                                'param_name' => 'data',
                                'admin_label' => true,
                            ),
                            array(
                                'type' => 'textfield',
                                'value' => '',
                                'heading' => 'Style',
                                'param_name' => 'style',
                            ),
                            array(
                                'type' => 'textfield',
                                'value' => '',
                                'heading' => 'Class',
                                'param_name' => 'class',
                            )
                        )
                    ),
                    array(
                      "type" => "checkbox",
                      "class" => "",
                      "heading" => "hide_header",
                      "param_name" => "hide_header"
                  ),
                    array(
                         "type" => "textfield",
                         "holder" => "",
                         "class" => "",
                         "heading" => "Class",
                         "param_name" => "class"
                    ),
      ),
    )
);

vc_map( array(
    "name" => "Simple_tablerow",
    "description" => "simple_tablerow",
    "base" => "simple_tablerow",
    "class" => "simple_tablerow",
    "content_element" => true,
    "as_child" =>  array('only' => 'simple_table'),
    "show_settings_on_create" => true,
    "icon" => "hide_header",
    "category" => __('Content', 'js_composer'),
    "params" => array(
        array(
            'type' => 'param_group',
            'value' => '',
            'param_name' => 'cols',
            "heading" => "Cols",
            'params' => array(
                array(
                    'type' => 'textfield',
                    'value' => '',
                    'heading' => 'Data',
                    'param_name' => 'data',
                    'admin_label' => true,
                ),
                array(
                    'type' => 'textfield',
                    'value' => '',
                    'heading' => 'Style',
                    'param_name' => 'style',
                ),
                array(
                    'type' => 'textfield',
                    'value' => '',
                    'heading' => 'Class',
                    'param_name' => 'class',
                )
            ),
        ),
        array(
            'type' => 'textfield',
            'value' => '',
            'heading' => 'Class',
            'param_name' => 'class',
        )
    ),
    )
);

How can I add my nested shortcodes available in container like tabs, tour, accordion or Pageable Container ?

Note : The parameter "allowed_container_element" seems to be the cause, but how do I modify this value ?

Inglebard
  • 427
  • 5
  • 14

2 Answers2

2

Hopefully you found the answer to this already, since this is a bit old, but I was searching for an answer myself and this came up.

This documentation site might be of use to you https://kb.wpbakery.com/docs/developers-how-tos/nested-shortcodes-container/

If I had to guess, it seems you forgot the last bit of code at the bottom where you extend the WPBakeryShortCodesContainer

//Your "container" content element should extend WPBakeryShortCodesContainer class to inherit all required functionality
if ( class_exists( 'WPBakeryShortCodesContainer' ) ) {
  class WPBakeryShortCode_Your_Gallery extends WPBakeryShortCodesContainer {
  }
}
if ( class_exists( 'WPBakeryShortCode' ) ) {
  class WPBakeryShortCode_Single_Img extends WPBakeryShortCode {
  }
}
zx485
  • 28,498
  • 28
  • 50
  • 59
Tojikan
  • 21
  • 2
0

It's been over 3 years from original question, but i had similar problem. Removing the following line worked for me:

"is_container" => true,
Dalias
  • 1
  • 1