Our Biggest Sale Is Here
Up to 70% Off
Get the Deal

How to show one table cell with a shortcode in wpDataTables

Say your price list is a wpDataTables table, and your homepage says “Our standard plan costs 29 EUR a month”. When the price changes in the table, you don’t want to update the homepage by hand. The wpdatatable_cell shortcode shows the value of one cell anywhere you can use a shortcode, and it always shows the current value from the table. Its parameters depend on the table type: Simple tables use the row number and column letter, and data tables use the column name and a row ID.

How do I show a cell from a Simple table?

Use the table ID, the row number and the column letter, the same way you address a cell in Excel:

[wpdatatable_cell table_id=1 row_id="1" column_key="A"]
Parameter Value
table_id The ID of the Simple table, shown on the Tables list and in its shortcode.
row_id The row number, starting at 1.
column_key The column letter, for example A, B or C.

For a merged cell, use the row and column where the merged cell starts. If A1, B1 and C1 are merged, column_key="A" shows the value, while column_key="B" and column_key="C" show nothing.

How do I show a cell from a data table?

For data tables, such as tables from a file, a MySQL query or a manual table, you name the column and find the row either by its row ID or by a value in a column with unique values.

How do I find the row by its ID?

Give the column and the row ID:

[wpdatatable_cell table_id="1" row_id="1" column_key="price" sort="1"]

The row ID depends on the table type:

Table type Row ID
Table linked to Excel, CSV, XML, Google Sheets or a PHP array (without server-side processing) The row index
MySQL query table The value of the ID column for editing, or of the first column if none is set
Manual table The value of the wdt_ID column
Table from Gravity Forms, Formidable Forms or Forminator The entry ID

How do I find the row by a unique value?

Name a column with unique values and the value to look for. This example shows the price from the row where the column sku is PLAN-STD:

[wpdatatable_cell table_id="1" column_key="price" column_id="sku" column_id_value="PLAN-STD" sort="1"]

For column_id_value you can also use the placeholder %CURRENT_USER_ID%, to show a value from the row of the logged-in user.

Both ways use these parameters:

Parameter Value
table_id The ID of the table.
column_key The original header of the column that holds the value.
row_id The row ID, as in the table above.
column_id The original header of a column with unique values.
column_id_value The value to look for in column_id.
sort 1 (default) reads the data with the table’s sorting, 0 reads it without sorting.

The original header is the column name from the source, such as the CSV header or the MySQL column name. It is not the Displayed header in the Display tab of the column settings, which only changes the header visitors see.

  • If column_id_value matches more than one row, only one value is shown.
  • Filters and pre-filtering don’t apply: the value comes from the source no matter what the table shows.
  • Float, formula, date, datetime and time columns can’t be used as column_id.
  • column_key and column_id can’t be the same column.
  • If an integer column of a MySQL query table is the row ID, write the number without the thousands separator.

What should I remember about the single cell shortcode?

Use wpdatatable_cell to show one current value from a table in any post or page. For Simple tables give the row number and the column letter; for data tables give the column’s original header and either the row ID or a unique value with column_id and column_id_value. Filters don’t apply, and float, formula, date and time columns can’t identify the row.

Wait, Before You Download!

To get your hands on wpDataTables Lite, please enter your email address below. We’ll send you a direct download link and keep you updated on existing features along with helpful tips and tricks!

By continuing, I accept Privacy Policy and T&C
Mail Box