Im trying to build a shortcode which calls an HTML table with a fixed number of columns and a variable number of rows depending on the context.
Its hard to manage — or even build, multiple tables over and over through HTML. I’ve had no trouble creating fixed columns and rows through shortcodes.
To illustrate through the usage of a trivial example:
Lets assume i build a table with 4 columns and 1 row.
The 4 columns will contain the following table headers:
- Product name
- Quantity
- Price per item
- Total price
What if i wanted to create multiple rows (Product 1, Product 2 etc..), if at all possible, how can i build a shortcode that enables me to add more rows as i see fit — without creating a separate shortcode for table rows (been there).
pass your data in single variables delimited by some char:
then explode it into an array and output. I didn’t bother with table markup here, but you get the idea: