Plugin Author
samsk
(@samsk)
This plugin does post-processing on frontend (in browser).
So once you have some table with specific ID, just use anywhere plugin shortcode with that ID. When viewing affected page, plugin will generate javascript, that will instantiate datatables on given table ID.
There is no frontend, datatables are too powerfull and complicated for that.
For static table just add shortcode after that table.
Example:
<table id="table1">
<thead>....
<tbody>....
</table>
[wp-datatable id="table1"]
responsive: true
[/wp-datatable]
Thread Starter
oscare
(@oscare)
Thank you for the quick response.
Can use this plugin with a table that is generated from a MySQL query?
If so, where do I place the code?
Plugin Author
samsk
(@samsk)
Not sure what do you mean with ‘table generated from a MySQL query’, if I can not see it, i’cant give you exact advice.
But, you should be able to use the shortcode anywhere. The javascript init part executed once the document is ready => jQuery().ready()
Thread Starter
oscare
(@oscare)
I have a plugin that does this:
It has a query like $query = ‘SELECT * FROM users’
That query gives me the results like:
$result = $wpdb->get_results($query, ARRAY_A);
With $results I build a table.
Now, I want to have that table to become a DataTables table.
Where can I apply the shortcode?
If the shortcode does not work, then how can I instanciate your plugin?
Plugin Author
samsk
(@samsk)
Use the shortcode within somewhere with page or post – I don’t know how your table is included.
From plugin itself you can always use do_shortcode() function.