add_ux_builder_shortcode:如何在 WordPress 中创建具有 Flatsome 主题(UX Builder)的自定义容器元素?

问题描述 投票:0回答:1

如何在 Wordpress 中创建具有 Flatsome 主题(UX Builder)的自定义容器元素?

下面添加一个元素:

    // Add a new custom container to UX Builder
    add_ux_builder_shortcode('custom_container', array(
        'name' => __('Custom Container'),
        'category' => __('Content'),
        'wrap' => false, // to prevent UX Builder from adding additional div around our container
        'options' => array(
            'image2' => array(
                'type' => 'image',
                'heading' => __('Image'),
                'group' => 'General'
            ),
        ),
    ));

    // Function to handle the output of the custom container
    function shortcode_custom_container($atts, $content = null) {
        extract(shortcode_atts(array(
            'background' => '#fff',
        ), $atts));

        // The do_shortcode function will process any nested shortcodes
        return '<div class="custom-container" style="background-color:' . $background . '">' . do_shortcode($content) . '</div>';
    }

    // Register the shortcode
    add_shortcode('custom_container', 'shortcode_custom_container');

但是,

为什么custom_container元素不能包含子元素?

感谢您的支持!

wordpress wordpress-theming wordpress-shortcode
1个回答
0
投票

找到我的答案...

add_ux_builder_shortcode('custom_container', array(

    // [...]

    'type' => 'container',

    // [...]
© www.soinside.com 2019 - 2024. All rights reserved.