Can Microthemer add column/row to existing table?

Author Posts

martg

Hi,

My question as above. If yes, how to do it?

Thanks.


Sebastian

Hi there,

Unfortunately not. Microthemer can’t be used to add new content to the page. It can only be used to style existing content (by generating CSS code). If you want to add another table row, you will need to edit the page’s HTML via the Text tab of the WordPress Post/Page editor, or edit a theme file directly if the table isn’t editable from your WordPress dashboard.

However, if you know a bit of JavaScript, you could insert an extra table row dynamically (Microthemer has a JavaScript tab in the custom code view for quickly adding JS code to your site). This method is a bit ‘hacky’ and I wouldn’t normally recommend it. But if this seems like the most doable option, the following jQuery code might do the trick:

$(document).ready(function(){
$("table.something").append('<tr><td>first col</td><td>second col</td></tr>');
});

Note: you would need to replace table.something with a valid CSS selector for targeting the table. And if the table uses tbody, include that at the end too e.g. table#my-selector tbody. Also, this code assumes only two columns. You will need to adjust the number of td elements if you have more or less columns in your table.

I hope that helps. I’m here if you have further questions.

Cheers,
Sebastian

You must login or register to reply to this topic.