Most of the users need to show a single value from their tables. wpDataTables presents dynamic single-cell shortcodes that you can use in many different options. There are differences in shortcode parameters depending on the table type. So let’s begin.
Table of Contents
Video tutorial
Simple table: Instructions for using the single cell shortcode
As you know, Simple tables have a different layout and structure then other datatables in the plugin. To show cell content you will need to use this:
[
wpdatatable_cell table_id=1 row_id="1" column_key="A"
]
where:
- table_id – is the ID of your Simple table
- row_id – is the ID of the Simple table row
- column_key – is name of the column ( ex. A or B or C…)
Using single cell shortcode for datatables
For DataTables, the single-cell shortcode can be used in two ways:
1. [
wpdatatable_cell table_id="1" row_id="1" column_key="column_name" sort="1"
]
Where:
- table_id – is the ID of your DataTable
- row_id – is the ID of the DataTable table row (different for each type):
- for non-server-side tables created from an external source (Excel, CSV, XML, Google Sheet, or PHP Array) the value from the row index will be used.
- for SQL-based tables, the value from the column “ID column for editing” will be used. Or, if this is not set, the first column in the table will be used.
- for manual tables, the value from wdt_ID column will be used.
- for tables created using Form builders (Gravity, Formidable, or Forminator) the value from Entry ID will be used.
- column_key – is the name of the column ( origin header* of the column)
- sort – by default it is set to “1” (sorting table is automatically enabled). If you need to fetch data from a source without sorting, you will provide the value “0”
2. [
wpdatatable_cell table_id="1" column_key="column_name" column_id="custom_id_column" column_id_value="custom_id_column_value" sort="1"
]
Where:
- table_id – is the ID of your DataTable
- column_key – is the name of the column from which the single-cell value will be pulled (origin header* of the column)
- column_id – is the name of the column that contains unique values (origin header* of the column)
- column_id_value – is the value from column_id column (here you can also use placeholder %CURRENT_USER_ID% as value)
- sort – by default it is set to “1” (sorting table is automatically enabled). If you need to fetch data from a source without sorting, you will provide the value “0”
* origin header – you can see it in the wpDataTables configuration page when you open the column settings panel by clicking on the “Column settings” button or by clicking the “Column list” button above the table from where you can open column configuration for each column.