TablePress Shortcodes

Below, you’ll find a detailed guide on how to add the TablePress Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the TablePress – Tables in WordPress made easy Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the TablePress Plugin and the shortcodes it provides:

Plugin Icon
TablePress – Tables in WordPress made easy

"TablePress is a user-friendly plugin that simplifies creating and managing tables in WordPress. Ideal for organizing data, creating comparison charts, or showcasing product features."

★★★★★ (4496) Active Installs: 800000+ Tested with: 6.3.2 PHP Version: 5.6.20
Included Shortcodes:
  • [tablepress]
  • [table-info]

TablePress [tablepress] Shortcode

The TablePress shortcode is used to display and manage data in tables within WordPress. This shortcode supports a variety of attributes allowing customization of table content, layout, and functionality. It checks if a table with a given ID exists, loads the table data, and handles error scenarios. The shortcode also enables caching for table output and integrates with DataTables JavaScript library for advanced features.

Shortcode: [tablepress]

Parameters

Here is a list of all possible tablepress shortcode parameters and attributes:

  • id – Unique identifier of the table
  • alternating_row_colors – Toggle alternate row coloring
  • datatables_sort – Enable or disable table sorting
  • datatables_paginate – Turn on or off table pagination
  • datatables_paginate_entries – Set number of entries per page
  • datatables_lengthchange – Allow or disallow change in number of entries per page
  • datatables_filter – Enable or disable table filtering
  • datatables_info – Show or hide table information
  • datatables_scrollx – Enable or disable horizontal scrolling
  • datatables_scrolly – Enable or disable vertical scrolling
  • datatables_locale – Set the language for the table
  • datatables_custom_commands – Add custom commands for the table
  • cache_table_output – Enable or disable caching of table output
  • shortcode_debug – Enable or disable debugging of shortcode

Examples and Usage

Basic Example – A simple way to display a table with a specific ID.

[table id=1 /]

Advanced examples

Display a table with a specific ID and enable DataTables features like sorting, pagination, and filtering.

[table id=1 datatables_filter=true datatables_sort=true datatables_paginate=true /]

Display a table with a specific ID and disable DataTables features like sorting, pagination, and filtering.

[table id=1 datatables_filter=false datatables_sort=false datatables_paginate=false /]

Display a table with a specific ID, enable DataTables features and specify the number of entries for pagination.

[table id=1 datatables_paginate_entries=10 /]

Display a table with a specific ID and enable horizontal scrolling for wide tables.

[table id=1 datatables_scrollx=true /]

Display a table with a specific ID and enable vertical scrolling for long tables.

[table id=1 datatables_scrolly=true /]

Display a table with a specific ID and specify a custom command for DataTables.

[table id=1 datatables_custom_commands="order: [[ 1, 'asc' ]]" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tablepress] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( TablePress::$shortcode, array( $this, 'shortcode_table' ) );

Shortcode PHP function:

Code file location:

tablepress/tablepress/controllers/controller-frontend.php

TablePress [table-info] Shortcode

The TablePress shortcode is a powerful tool that fetches and displays table data. . It accepts parameters like ‘id’, ‘field’, and ‘format’. The ‘id’ is used to identify the specific table, ‘field’ specifies the table data to fetch, and ‘format’ determines the data’s presentation. This shortcode is flexible, allowing for various data types like ‘name’, ‘description’, ‘last_modified’, ‘last_editor’, ‘author’, ‘number_rows’, and ‘number_columns’. It also includes filters for customizing the output.

Shortcode: [table-info]

Parameters

Here is a list of all possible table-info shortcode parameters and attributes:

  • id – The unique identifier of the table
  • field – Specifies the field to be displayed
  • format – Determines the format of the output

Examples and Usage

Basic example – Display a table using its unique ID

[table-info id="123" /]

Advanced examples

Display the name of a table using its ID

[table-info id="123" field="name" /]

Display the last time a table was modified in a human-readable format

[table-info id="123" field="last_modified" format="human" /]

Show the number of rows in a table excluding the header and footer

[table-info id="123" field="number_rows" format="raw" /]

Display the name of the last editor of a table

[table-info id="123" field="last_editor" /]

Show the author of a table

[table-info id="123" field="author" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [table-info] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( TablePress::$shortcode_info, array( $this, 'shortcode_table_info' ) );

Shortcode PHP function:

Code file location:

tablepress/tablepress/controllers/controller-frontend.php

Conclusion

Now that you’ve learned how to embed the TablePress – Tables in WordPress made easy Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *