ACF Table Field Pro Add-on Docs

Select plugin version:

Since version: v1.5.0

Please note and understand

This page content is a preview/draft of an upcoming plugin version and is not yet applicable to the latest public plugin version. The content of this page may change or not be implemented.

View Table with PHP

Default HTML Table

Using get_field() is the default way to get the table HTML. You can hook into the HTML rendering by filters and actions.

echo get_field('acf_field_name');

Custom Rendering Table Data

Using get_field() with the second parameter false returns the raw table fields data as stored in the database. Please do not rely on this raw field data as its structure may change. Instead, PHP class ACFTablefield can be used to continue working with this data as in the following code example. The ACFTablefield PHP class provides methodes to get table data, options and field settings. The class also allows changing table data and updating a table field.

$table_data = get_field('acf_field_name', false); 
$tablefield = new ACFTablefield( $table_data ); 
 
if ( $tablefield->has_body_data() ) { 
 
	$table_body = $tablefield->get_table_body_data(); 
 
	foreach ( $table_body as $row ) { 
 
		foreach ( $row as $cell ) { 
 
		} 
	} 
}

Previous and Next Sources

Parent sources