Template Tag Functions

To show a table in places not covered by blocks or Shortcodes (e.g. in your page footer or in the sidebar) you can use the Template Tag Function tablepress_print_table( $query );. It can be added to any part of your theme (between PHP brackets: <?php and ?>).

The parameter $query can be a string in the form of a query string in a URL or other WordPress functions like wp_list_pages(), or it can be a an array with the query parameters and values.

If you don’t want to immediately print the table, but just get the output, use tablepress_get_table( $query );, which works the same way.

The possible parameters are the same as for the Shortcode.

Example with $query as a string:

<?php tablepress_print_table( 'id=1&use_datatables=true&print_name=false' ); ?>Code language: PHP (php)

Example with $query as an array (recommended and easier to read):

<?php tablepress_print_table( array( 'id' => '1', 'use_datatables' => true, 'print_name' => false ) ); ?>Code language: HTML, XML (xml)

There’s a also a Template Tag Function for the Shortcode

[table-info id=N field="<field-name>" /]Code language: JSON / JSON with Comments (json)

available:

<?php tablepress_print_table_info( "id=1&field=name" ); ?>Code language: PHP (php)

or

<?php tablepress_print_table_info( array( 'id' => '1', 'field' => 'name' ) ); ?>Code language: PHP (php)

It works exactly as the Template Tag Function described above, with the parameters from the section about the [table-info /] Shortcode.