1

How can I create a custom container element with Flatsome theme (UX Builder) in Wordpress?

The following adds an element:

    // 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');

However,

Why can't the custom_container element contain child elements?

Thank you for the support!

1 Answer 1

2

Found my answer...

add_ux_builder_shortcode('custom_container', array(

    // [...]

    'type' => 'container',

    // [...]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.