• Resolved Mor

    (@superbrightfuturegmailcom)


    Is there a way of making wp shortcode even shorter?
    What I want to do is
    [i=134]

    instead of say
    [i i=134]

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Sorry for having to kick you over to this forum. It’s a common occurrence!

    Someone smarter than I may have something I don’t know, but as far as I know, that isn’t possible.

    The shortcode API looks for a shortcode first, and then for the attribute/value pair. Without a change to core, just can’t do it, afaik.

    Thread Starter Mor

    (@superbrightfuturegmailcom)

    Could you not… make a plug-in (or function?) that replaces shortcode where the shortcode is immediately followed by an equal sign? So you’d type [i=134] but the plugin would find it and automatically turn it into [i i=134] before the shortcode API got to it?

    Brandon Kraft

    (@kraftbj)

    Code Wrangler

    I suppose you could; I’m not familiar with which filter/hook you would tie into to process $content before the shortcode process starts. I don’t know if there is a way to modify the shortcode process itself, short of editing core.

    Depending on end goal, that may not be worth the resources to, in effect, double the work of the shortcode process.

    Thread Starter Mor

    (@superbrightfuturegmailcom)

    2 months later and I found out how to do it, in the codex, of all places.

    http://codex.ww.wp.xz.cn/Shortcode_API

    “Other features in brief

    For backwards compatibility with older ad-hoc shortcodes, attribute names may be omitted. If an attribute has no name it will be given a positional numeric key in the $atts array. For example, [myshortcode 123] will produce $atts = array( 0 => 123 ). Positional attributes may be mixed with named ones, and quotes may be used if the values contain spaces or other significant characters.”

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Shorter shortcode?’ is closed to new replies.