Как показать новый пользовательский мета-блок в визуальном компоновщике в интерфейсе - PullRequest
0 голосов
/ 10 июня 2018

У меня есть пользовательский мета-бокс для визуального композитора и он работает нормально. Административный раздел

add_action( 'vc_before_init', 'custome_team_section_createWithVC' );


function custome_team_section_createWithVC() {
   vc_map( array(
      "name" => esc_html__( "Custome Team Box", "custome" ),
      "base" => "team_box",
      "category" => "Custome",
      "params" => array( 

        array(
            'type' => 'attach_image',
            'heading' => esc_html__( 'Member Image', 'custome' ),
            'param_name' => 'image_url',
            'description' => esc_html__( 'Add Member Image', 'custome' ),
        ),  

        array(
            "type" => "textfield",
            "heading" => esc_html__("Name", "custome"),
            "param_name" => "name",
            "description" => esc_html__("Add member name.", "custome"),
        "adm    in_label" => true,
        ),    

        array(
            "type" => "textfield",
            "heading" => esc_html__("Job", "custome"),
            "param_name" => "position",
            "description" => esc_html__("Add member position.", "custome"),
        ),

        array(
            "type" => "textarea",
            "heading" => esc_html__("About Member", "custome"),
            "param_name" => "contentm",
            "description" => esc_html__("Add content about the member.", "custome"),
        ),

        array(
            'type' => 'param_group',
            'heading' => esc_html__( 'Social', 'custome' ),
            'param_name' => 'social',
            'value' => urlencode( json_encode( array(
                array(
                    'title' => esc_html__( 'facebook', 'custome' )
                ),
            ) ) ),
            'group' => 'Social',
            'params' => array(
                array(
                    'type' => 'vc_link',
                    'heading' => esc_html__( 'URL (Link)', 'custome' ),
                    'param_name' => 'link',
                    'description' => esc_html__( 'Add a url for social box.', 'custome' ),
                ),  

                array(
                    'type' => 'iconpicker',
                    'heading' => esc_html__( 'Icon', 'custome' ),
                    'param_name' => 'icon_fontawesome',
                    'value' => 'fa fa-info-circle',
                    'settings' => array(
                        'emptyIcon' => false, // default true, display an "EMPTY" icon?
                        'iconsPerPage' => 200, // default 100, how many icons per/page to display
                    ),
                    'description' => esc_html__( 'Select icon from library.', 'custome' ),
                    'admin_label' => true,
                ),

            )
        ),

      ),
   ) );
}

, но я не знаю, как он будет отображать контент в интерфейсе. Я использую стандартную тему WordPress двадцать.семнадцать, и когда я проверяю интерфейс после создания страницы с этим мета-блоком, отображаются короткие коды по умолчанию, показанные на изображении

enter image description here

какой у меня кодиспользовать в файле functions.php или page.php, чтобы он правильно отображал пользовательский мета-блок в интерфейсе

Спасибо

1 Ответ

0 голосов
/ 10 июня 2018

Пожалуйста, не называйте это «пользовательским мета-боксом», это что-то еще, прочитайте здесь .

Вы добавляете свой пользовательский короткий код на страницу WPBakery.Builder (ранее Visual Composer) с vc_map(), но вы забыли зарегистрировать шорткод.Вот почему вы видите шорткод на интерфейсе.Построитель страниц - это, по сути, гигантский генератор коротких кодов.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * * * * * * *1013* *1013*

Добавьте шорткод так:

add_shortcode( 'team_box', 'team_box_callback' );
function team_box_callback( $atts ) {
  extract( shortcode_atts( array(
    'image_url' => 'image_url',
    'name' => 'name',
    // add your other field param_name here
  ), $atts ) );

  $your_html_shortcode_output = 'u can now use the shortcode attributes like normal params, like this: ' . $name;

  return $your_html_shortcode_output;
}

Более подробную информацию о vc_map() можно найти здесь .

С уважением, Бьорн

...