Black friday Black friday Black friday Cyber monday Cyber monday Cyber monday
Up to 70% off Up to 70% off
Grab Yours

Single cell shortcode

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.

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…)

If you need to show a merged cell, you will need to provide a column and a row where that merged cell starts. For example, if you merge cells A1, B1, and C1, you would use the following shortcode:

[wpdatatable_cell table_id=1 row_id="1" column_key="A"]

Please note that this will not work for other columns like:

[wpdatatable_cell table_id=1 row_id="1" column_key="B"]
[wpdatatable_cell table_id=1 row_id="1" column_key="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 column-config or by clicking the “Column list” button above the table from where you can open column configuration for each column.

Origin header in wpdatatables

Please note:

  • If you use the second option with column_id and column_id_value and if you provide a value that is not unique which returns more values (rows) – only one will be shown.
  • Pre-filtering is not included (value will be returned from a source based on shortcode parameters no matter if it is shown in the filtered table).
  • At the moment float, formula, date, datetime, and time columns can not be used as column_id. Please use another column that contains unique identifiers.
  • Parameters column_key and column_id can not be the same.
  • When using an integer field as the ‘row_id‘ in an SQL Query-based Table, make sure to ‘skip’ the thousands separator in the shortcode.
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