shortcode – multiple instances of same parameter name in one shortcode instance

I’m looking to include a shortcode that builds a table of items and groups of items. For this I wish to be able to include an attribute multiple times or chain them together in some way. An example is I would like to do something like this:

[testcode item=”item1″ group=”group1″ item=”item2″ item=”item3″ group=”group2″]

alternatively something like this could work:

[testcode item=”item1″&group=”group1″&item=”item2″&item=”item3″&group=”group2″]

The order the parameters appear must be maintained and multiple entries must be allowed. Any suggestions on how to accomplish this without writing completely custom shortcode handler routines?

An array does not seem to maintain the order between items and groups and associative arrays do not seem to be allowed in shortcodes. What I’m looking for is identifying and maintaining item1,group1,item2,item3,group2 order when I process it.

Solutions Collecting From Web of "shortcode – multiple instances of same parameter name in one shortcode instance"

Shortcodes are intended to be used by humans, to be some kind of macro that even the most techno-phobic author can use. If you need to have arrays of attributes, or any other complex structure for which the author has to attend CS 101 in order to understand its use, your shortcode is just a fail.

If you need a shortcode with complex data, the more sane way to do it is by separating the placement and the actual data input. Create a meta box section in which users can have a nice UI in inputting the data, and use [myshortcode] in the text just as an indication where that data should be displayed.