• Hey,
    Today I encountered an “issue” with a custom shortcode. So I’m doing basically just something like this:

    function bartag_func( $atts ) {
    	$atts = shortcode_atts( array(
    		'foo' => 'no foo',
    		'baz' => 'default baz'
    	), $atts, 'bartag' );
    
    	return "foo = {$atts['foo']}";
    }
    add_shortcode( 'bartag', 'bartag_func' );

    The shortcode itself works fine, where I got a headache, was when I forgot in a long article just to close the shortcode. So I had

    [bartag foo="test" 
    // ... a lot of stuff ... 
    [bartag foo="test2"]

    It seems to work, because the other shortcode closed it? But it swallowed all my content in between without complaining about it. I think this should be handled somehow.

    Can I e.g. check manually for content length of the shortcode?

Viewing 1 replies (of 1 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I’ve shot myself in the foot with the same sort of thing. The shortcode parser keeps going from the first [ until it finds a ]. There’s no way for WP to figure out that you forgot to close the shortcode.

Viewing 1 replies (of 1 total)
  • The topic ‘Handle unclosed shortcodes’ is closed to new replies.