Інструменти та техніки для усунення проблем з даними полів.
Вивантажити всі поля для поста
php
// 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>';
}Перевірити сирі значення бази даних
php
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>';Перевірити відповідність групи полів
php
// Check which field groups match a specific post
$groups = FIELDFORGE_Field_Groups::instance()->get_all();
$post = get_post( 42 );
foreach ( $groups as $group ) {
$matches = FIELDFORGE_Field_Groups::instance()->evaluate_location_rules(
$group->location_rules,
$post
);
echo esc_html( $group->title ) . ': ' . ( $matches ? 'MATCH' : 'no match' ) . '<br>';
}Увімкнути журнал запитів
php
// Log all Field Forge database queries
add_filter( 'fieldforge/load_value', function( $value, $field_name, $post_id ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( sprintf( 'FF get_field: %s for post %d = %s',
$field_name, $post_id, print_r( $value, true )
) );
}
return $value;
}, 10, 3 );—