Use [shortcode=”value”] instead of [shortcode att=”value”]?

I thought this was a rather good question, so I tinkered with it a little. It seems as though the catch to using the direct method ([icon='myicon']) vs using an attribute is that with the direct method, you cannot use spaces as it will split to separate attributes, even if you use quotation marks, and the quotation marks and equals sign are considered part of the value. For example: a print_r( $atts ) on [dev_dump http://example.com/test.jpg] returns Array ( [0] => http://example.com/test.jpg ), whereas a print_r( $atts ) on [dev_dump='my icon'] returns Array ( [0] => ='my [1] => icon' ). That said, however, [dev_dump foo='bar' http://example.com/test.jpg] does give you Array ( [foo] => bar [0] => http://example.com/test.jpg ), so as long as there is only ONE unlabeled value, you should be pretty safe to use that method, as you can just use $atts[0]. Be careful with setting up defaults, as I can see that becoming tricky and buggy relatively quickly.

Thanks for asking a great question, really made me think!

Leave a Comment