Hello! A couple months ago I started my WordPress journey, I needed to build a page in which I needed to query a database and output to page. I ended up setting up a REST endpoint that returns a JSON that I look through to build an HTML table.
Now, the formatted table, for some reason I don’t completely understand, doesn’t take on any of my CSS, so I cannot make it responsive on mobile.
Before I try to fix that, is there a recommended way of programatically building a table and showing it that I don’t know of? Preferably without using an external plugin, or a plugin I don’t need to pay for even if it needs a little bit of tinkering.
[ad_2]
Tables don’t generally work well on mobile, simply due to width… tables are wide, and don’t collapse – that’s really all there is to it.
I built a dynamic horizontally scrolling comparison table that uses custom post type data to populate. You need knowledge of PHP, HTML, CSS, JS (if you want to add sorting) and WP functions to make it happen.
There are plenty of responsive table tutorials out there if you want a truly responsive table.
One method works like this, where you use data attributes and make each row its own section on mobile:
https://codepen.io/jlevin/pen/JveWxx