2

I try to make a shortcode like

add_shortcode( 'test', 'test' );
function test( $atts, $content = null ) {
    $html = '<div>'.do_shortcode( $content ).'</div>';
    return $html;
}

I try some thing like [test][test]this is test[/test][/test] But that not working.

enter image description here

How to fix that. Thanks

1
  • can you post code? Commented Dec 24, 2016 at 11:35

1 Answer 1

1

This is a limitation of the shortcode parser.

You can check out this entry from the Codex on the shortcode API, where it says:

However the parser will fail if a shortcode macro is used to enclose another macro of the same name:

[tag-a]   
    [tag-a]    
    [/tag-a] 
 [/tag-a]

This is a limitation of the context-free regexp parser used by do_shortcode() - it is very fast but does not count levels of nesting, so it can't match each opening tag with its correct closing tag in these cases.

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

1 Comment

birgire is right. You can use it like this [test][test_a]content here[/test_a][/test]

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.