Skip to content

Shortcode Reference ​

This page lists every shortcode Ninja Tables provides, each attribute with its default, and the placeholders you can use inside shortcode filters. Follow the links for examples and the reasoning behind each option.

Shortcodes ​

ShortcodeWhat it showsFree / Pro
[ninja_tables id="123"]A table.Free (most attributes are Pro)
[ninja_table_builder id="123"]A Drag & Drop table.Free
[ninja_table_info id="123" field="title"]A detail about a table.Free
[ninja_table_cell id="123" row_id="45" column="price"]The value of one cell.Free
[nt_ratings value="4"]A star rating, for use in cells.Pro
[nt_icon icon="check"]An icon, for use in cells.Pro
[ninja_charts id="1"]A chart. Comes from the separate Ninja Charts plugin.Free

Charts are covered in Add a Chart to a Page.

[ninja_tables] ​

The table shortcode. Add attributes inside the brackets; examples and use cases are in Advanced Shortcode.

Free attributes ​

AttributeDefaultPurpose
idnoneTable ID. Required.
filternoneShow only matching rows. Visitors can still search. Syntax (AND, OR, -exclude, "phrase"): Default Data Filtering Shortcode. Placeholders in it need Pro.
use_parent_widthoffMake the table use its container's width.
infoemptyPage-info line after the pagination, for example info="Page {CP} of {TP}". FooTable engine only: it has no effect on DataTables tables.

Pro attributes ​

Pro attributes are ignored when Ninja Tables Pro is not active.

AttributeDefaultValuesPurpose
per_pagetable settingA numberRows per page.
searchtable setting1 or 0Show or hide the search box.
sortingtable setting1 or 0Turn column sorting on or off.
hide_headertable setting1 or 0Hide the header row.
logged_in_onlyoff1Show the table to logged-in visitors only.
columnsallComma-separated column keysShow only these columns. Match the column key, not its title.
skip0A numberSkip the first rows of the data.
limit0 (no limit)A numberShow at most this many rows.
filter_columnnoneComma-separated column keysApply filter to these columns only.
hide_default_filteroffyesKeep rows hidden by filter hidden even after a visitor resets the filters.
get_filternoneA query-parameter nameTake the filter from the page address, for example ?dept=Sales.
filter_selectsnoneFilter title=Value|Other filter=ValuePre-select values in the table's custom filters.
sf_filternoneText or a placeholderA locked filter value visitors can't clear. Needs sf_column.
sf_columnnoneA column keyThe column the locked filter applies to.
sf_matchequalequal, contains, lt, gt, startswithHow sf_filter is compared with the cell.
stackableoffyesStack rows as cards for this embed.
stack_devicesxs,smxs, sm, md, lgDevices that get cards when stackable is on.
post_taxnonetaxonomy=term,term|taxonomy2=termFilter a WP Posts or WooCommerce table by taxonomy terms.
post_tax_fieldslugslug, name, term_idHow the terms in post_tax are matched.
disable_editnoyesTurn off frontend editing for this embed. Applies to tables with built-in rows.

Use 1 and 0, not "false" or "no"

search, sorting and hide_header turn on for any value except 0 or an empty value. Writing search="false" or hide_header="no" turns the feature on, not off. Always use 1 to turn on and 0 to turn off.

Details that are easy to miss:

  • sf_match="lt" and "gt" compare the cell with the filter value as PHP does, so keep both in the same format (for dates, the same date format). contains and startswith are case-sensitive on FooTable tables and not case-sensitive on DataTables tables.
  • logged_in_only renders nothing for logged-out visitors. Logged-in visitors see the table as usual.
  • get_filter can be combined with a column address parameter, and filter_selects can be overridden from the address. See Advanced Shortcode.
  • sf_filter works on DataTables tables (applied on the server) and on FooTable tables set to Legacy rendering. On a FooTable table in Ajax rendering it has no effect and every row is shown.

[ninja_table_builder] ​

Shows a Drag & Drop table. Its only attribute is id. Copy it from the shortcode chip in the builder. The table must be published, or nothing is printed. Logged-in table admins also see an Edit Table link below the table.

[ninja_table_info] ​

Prints one detail of a table inside any content.

AttributeValues
idTable ID. The table must be published, otherwise the text Error: Invalid table ID. is printed.
fieldtitle, description, total_rows, last_modified or last_editor.
  • total_rows counts rows only for tables that store their own rows; other sources print nothing.
  • last_modified is the time the table was last saved.
  • last_editor is the display name of the last editor, or the table author if there is none.

[ninja_table_cell] ​

Prints the value of one cell.

AttributeValues
idTable ID. The table must be published, otherwise it prints "Sorry! The table is not available."
row_idThe row's ID, for tables that store their own rows.
rowThe row's position (1 is the first row), for tables that read rows from elsewhere (WP Posts, CSV, Google Sheets and so on).
columnThe column key. A number also works and picks the column by its position.

A cell that itself contains a [ninja_table_cell] shortcode is resolved up to 5 levels deep.

Shortcodes inside table cells ​

Any shortcode you type into a cell, including [nt_ratings] and [nt_icon], runs only for tables whose rows are stored in Ninja Tables (typed in, imported or edited on the front end). Tables that read their rows from another source, such as Fluent Forms entries, show the shortcode text as it is. This stops values from outside sources from running code on your site.

[nt_ratings] and [nt_icon] ​

See Rating & Icon Shortcodes.

Placeholders (Pro) ​

Placeholders are replaced with live values when the page loads. Use them in the filter and sf_filter shortcode attributes, in conditional formatting and Transform value rules, and in the values and presets of custom filters.

PlaceholderBecomes
{date:FORMAT}Today's date in a moment.js-style format, for example {date:YYYY-MM-DD}. Without a format it is Y-m-d.
{date+N:FORMAT}The date N days from now, for example {date+7:YYYY-MM-DD}.
{date-N:FORMAT}The date N days ago, for example {date-30:M/D/YYYY}.
{date:timestamp}The current Unix timestamp.
{user:FIELD}A field of the logged-in user, for example {user:ID}, {user:user_email}, {user:display_name}.
{usermeta:KEY}A user meta value of the logged-in user, for example {usermeta:billing_city}.
{current_user_role}The logged-in user's role(s), comma-separated.
{current_post_id}The ID of the page or post showing the table.
{current_post_title}The title of that page or post.
{gt} or {greater}> (greater than).
{lt} or {lesser}< (less than).

For logged-out visitors, {user:...} and {usermeta:...} are empty.

WARNING

{current_user_role} returns nothing for logged-out visitors, and then the whole value it is part of is emptied, not just the placeholder. Don't combine it with other filter text if logged-out visitors can see the table.

Examples ​

Show only the logged-in user's own rows, where the email column holds the user's email:

[ninja_tables id="123" sf_column="email" sf_filter="{user:user_email}"]

Show rows with a date column in the last 7 days:

[ninja_tables id="123" filter="~{date-7:YYYY-MM-DD}:{date:YYYY-MM-DD}" filter_column="date"]

Custom SQL tables have their own placeholders ({prefix}, {current_user_id} and others); see Custom SQL Query.