• Resolved plaidflannel

    (@plaidflannel)


    I have a shortcode with more than 20 parameters, most of which can be strings of about 10 to 30 characters. For readability, I would like to enter them something like this:

    [mycode
    p1=”val1″
    p2=”val2″
    p3=”val3″

    p20=”val20″
    ]

    That seems not to work. Is there any alternative to putting the shortcode and its parameters all on one line?

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

    (@sterndata)

    Volunteer Forum Moderator

    Sorry, but no. The parser expects blanks.

    Kinds hacky but when in the HTML editor (eg NOT the visual editor), you can push the space bar until the code wraps. When saving WP will remove all the extra spaces but visually in the admin, it will look as if each attribute is on it’s own line.

    Thread Starter plaidflannel

    (@plaidflannel)

    I found a different, maybe better approach…

    My original task was populating a table with five to ten cells. Each cell used “float: left” to fill a number of columns (typically three) that would vary with screen width. The shortcode parameters were an image and a caption for each cell.

    The new approach is to create separate shortcodes to open the table, add one cell, and close the table. This results in seven to twelve consecutive shortcodes, but each has no more than two parameters and thus is quite readable.

    One problem is that having consecutive shortcodes separated by a single linefeed results in “<br /> being inserted between them by the shortcode parser. That messes up the formatting of the table.

    To solve that problem, I put two linefeeds between consecutive shortcodes. The table then formats correctly.

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

The topic ‘Can shortcode parameters be on separate lines?’ is closed to new replies.