Support » Plugins » Shortcode self-closing bug?

  • Hello,

    Based on the shortcode api, I wrote a plugin that had two versions of the shortcode.

    The first version involved just writing [PageThing] in a post. This would be the most common and simple usage.
    The second version was: [PageThing]pageurl[/PageThing], to include data from other sites. However, when both versions were used in the same post, it stopped to function. I.e:
    ——————————-
    My Stuff
    [PageThing]
    My friend’s stuff
    [PageThing]www.friendsurl.com[/PageThing]
    ——————————-

    Then, in (pseudo)code, I had:
    IF no shortcode content: Do this!
    ELSE: Do that!

    Didn’t work, because WP believed that everything between first and last shortcode was the content of just one shortcode – with the shortcode content:
    ————
    My friend’s stuff
    [PageThing]www.friendsurl.com
    ———–
    So, I assumed that it was because the first shortcode wasn’t enclosed.
    But changing [PageThing] to [PageThing /] made no difference.

    Since the API says both versions can be used, this is either a bug, or something that needs to be clarified in the API.

    I solved it by changing my code to use the attribute instead:
    [PageThing] and [PageThing url=”www.friendsurl.com”]

  • The topic ‘Shortcode self-closing bug?’ is closed to new replies.