wpDataTables

Product details

Q: Can I make (sortable) table using data from custom acf/metabox fields?

grzegorz.kalinowskiOct 16, 2023
Founder Team
Milos.J_Trafft

Milos.J_Trafft

May 15, 2024

A: Hello,
Yes, it is possible to make tables like that sortable in our Plugin.
Just please note, in regards to pulling the data, we do not have a native integration with the ACF Plugin,
so that can only be done through custom MySQL query-based tables. (https://wpdatatables.com/documentation/creating-wpdatatables/creating-mysql-based-wpdatatables/​)

A good way to achieve this can be experimenting using our WPDB SQL Query Constructor tool. (https://wpdatatables.com/documentation/creating-new-wpdatatables-with-table-constructor/generating-wordpress-db-queries-with-table-constructor/)

Please be advised that writing custom SQL Queries or debugging Queries does not fall under what our support covers.
You can check out this official page of WP codex, for help with writing custom Queries. (https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query​)

The sorting/or filtering may not work correctly with our server-side processing if you include:

-Accent graves ( ` ) around the table name
-JOIN functions
-UNION functions
-CONCAT functions
-sub-queries

So depending on how your final Query is, if you encounter any issue with sorting,
you can try to simplify the Query for our Plugin if possible.
If none of that helps, you can try preparing a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.

If you need help with that, you can see our video, where we show an example of using View in our plugin. (https://youtu.be/xCS6hlnwuZU​)

Kind regards.

Share
Helpful?
Log in to join the conversation