Problems with nested shortcodes

Asked

Viewed 24 times

0

Hello! I’m trying to use some nested shortcodes, but I’m not succeeding.

The shortcodes are these, in statement order in functions.php:

function p_generico_shortcode( $atts , $content = null )
{
    return '<p class="pov generico">' . do_shortcode($content) . '</p>';
}
add_shortcode( 'pov-generico', 'p_generico_shortcode' );

Second:

function f_moca_shortcode( $atts , $content = null )
{
    return '<p class="fala moca">' . do_shortcode($content) . '</p>';
}
add_shortcode( 'fala-moca', 'f_moca_shortcode' );

When trying to use:

[fala-moca]TEXT[pov-generico]OTHER TEXT[/pov-generico][/fala-moca]

I’m getting:

<p class="fala moca">TEXT</p>
<p class="pov generico">OTHER TEXT</p>

Instead of:

<p class="fala moca">TEXT<p class="pov generico">OTHER TEXT</p></p>

I noticed that when nesting shortcodes that return HTML with different elements (e.g. p and span) it processes correctly.

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.