P
P
Petr Volkhanov2018-04-28 16:32:41
WordPress
Petr Volkhanov, 2018-04-28 16:32:41

How to make nested shortcodes work in Wordpress?

How to make nested shortcodes work in Wordpress when one shortcode is nested in another?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
y0u, 2018-04-28
@y0u

Execute the do_shortcode() function inside the parent shortcode.
Example:

function parent_shortcode($atts, $content) {
    return 'Hello ' . do_shortcode($content);
}
function children_shortcode() {
    return "Children Shortcode";
}
add_shortcode('parent', 'parent_shortcode');
add_shortcode('children', 'children_shortcode');

// ****

[parent] [children] [/parent] // Hello Children Shortcode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question