Tools and techniques for troubleshooting field data issues.
Dump All Fields for a Post
// Quick debug dump
$fields = get_fields( get_the_ID() );
echo '<pre>' . esc_html( print_r( $fields, true ) ) . '</pre>';
// Detailed dump with field definitions
$objects = get_field_objects( get_the_ID() );
foreach ( $objects as $name => $obj ) {
echo '<div class="debug-field">';
echo '<strong>' . esc_html( $name ) . '</strong> (' . esc_html( $obj['type'] ) . '): ';
echo '<code>' . esc_html( print_r( $obj['value'], true ) ) . '</code>';
echo '</div>';
}Check Raw Database Values
global $wpdb;
// View raw stored values (bypasses formatting)
$raw = $wpdb->get_results( $wpdb->prepare(
"SELECT id, field_name, field_value, field_type, parent_id, row_index
FROM {$wpdb->prefix}fieldforge_values
WHERE post_id = %d
ORDER BY parent_id, row_index",
42
) );
echo '<table>';
echo '<tr><th>ID</th><th>Name</th><th>Value</th><th>Type</th><th>Parent</th><th>Row</th></tr>';
foreach ( $raw as $row ) {
echo '<tr>';
echo '<td>' . $row->id . '</td>';
echo '<td>' . esc_html( $row->field_name ) . '</td>';
echo '<td>' . esc_html( substr( $row->field_value, 0, 100 ) ) . '</td>';
echo '<td>' . esc_html( $row->field_type ) . '</td>';
echo '<td>' . $row->parent_id . '</td>';
echo '<td>' . $row->row_index . '</td>';
echo '</tr>';
}
echo '</table>';Verify Field Group Matches
get_for_post() returns the field groups whose location rules match a post (an empty array when none match). The function that checks one group is private, so there is no public per-group check.
// Which field groups match a specific post?
$groups = FIELDFORGE_Field_Groups::instance()->get_for_post( 42 );
if ( empty( $groups ) ) {
echo 'No field group matches this post';
}
foreach ( $groups as $group ) {
echo esc_html( $group->title ) . '<br>';
}Enable Query Logging
To see every database query, including the ones of Field Forge, turn on SAVEQUERIES in wp-config.php and read $wpdb->queries:
// wp-config.php
define( 'SAVEQUERIES', true );
// At the end of a template, with WP_DEBUG_LOG on
global $wpdb;
foreach ( $wpdb->queries as $q ) {
if ( false !== strpos( $q[0], 'fieldforge_' ) ) {
error_log( $q[0] );
}
}The fieldforge/load_value filter (arguments: value, field name, post ID, stored row) can log reads too, but it fires only when a value is loaded from the database. The top-level values of a post are read in one query and kept in the object cache for 300 seconds and in memory for the request, so repeated get_field() calls on the same post do not trigger it again:
add_filter( 'fieldforge/load_value', function ( $value, $field_name, $post_id, $row ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( sprintf( 'FF load: %s for post %d', $field_name, $post_id ) );
}
return $value;
}, 10, 4 );—