Display a custom PHP/HTML message using a simple named hook.
The value cannot be retrieved as the field isn’t saved as custom meta.
Render Field Hook
You can render any custom content using the native acf/render_field
hook. Usage example:
/*
* https://www.advancedcustomfields.com/resources/acf-render_field/
*/
add_action('acf/render_field/name=dynamic_message', 'my_acf_dynamic_message');
function my_acf_dynamic_message($field){
?>
<table class="wp-list-table widefat fixed striped">
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
</table>
<?php
}
Inline Render Callback
It is possible to render custom content directly within the field declaration when using local PHP field registration. Usage example:
acf_add_local_field_group(array(
'key' => 'group_my_field_group',
'title' => 'My Field Group',
'fields' => array(
array(
'key' => 'field_my_dynamic_message',
'label' => 'My Dynamic Message',
'name' => 'my_dynamic_message',
'type' => 'acfe_dynamic_message',
// Inline render callback
'render' => function($field){
?>
<table class="wp-list-table widefat fixed striped">
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
</table>
<?php
}
),
),
'active' => true,
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
));