This tool helps diagnose issues with Canto ACF integration.
❌ ACF Plugin Not Active: Advanced Custom Fields plugin is not active or not installed.
✅ ACF Plugin Active: Advanced Custom Fields is available.
get_field() calls to your theme files<?php
// Add this to your theme template (single.php, page.php, etc.)
// Display image field
$image = get_field('your_image_field_name');
if ($image): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>">
<?php endif; ?>
// Display gallery field
$gallery = get_field('your_gallery_field_name');
if ($gallery): ?>
<div class="gallery">
<?php foreach ($gallery as $image): ?>
<img src="<?php echo $image['sizes']['medium']; ?>" alt="<?php echo $image['alt']; ?>">
<?php endforeach; ?>
</div>
<?php endif; ?>
| ID | Title | Canto ID | URL | Preview | Actions |
|---|---|---|---|---|---|
| ' . esc_html( $attachment->ID ) . ' | '; echo '' . esc_html( $attachment->post_title ) . ' | '; echo '' . esc_html( $canto_id ) . ' | '; echo 'View File | '; echo '';
if (strpos($attachment->post_mime_type, 'image/') === 0) {
echo ' | ';
echo 'Details | '; echo '
No Canto attachments found. Try inserting an image via ACF first.
'; } } private function show_acf_fields($post_id) { if (!function_exists('get_field_objects')) { echo 'ACF plugin not available.
'; return; } $post = get_post($post_id); if (!$post) { echo 'Post not found.
'; return; } echo 'Post: ' . esc_html( $post->post_title ) . ' (' . esc_html( $post->post_type ) . ')
'; echo 'Status: ' . esc_html( $post->post_status ) . '
'; echo 'Frontend URL: ' . esc_url( get_permalink($post_id) ) . '
'; $fields = get_field_objects($post_id); if ($fields) { foreach ($fields as $field_name => $field) { echo 'Type: ' . esc_html( $field['type'] ) . '
'; echo 'Value:
'; echo '' . esc_html( print_r($field['value'], true) ) . ''; if ($field['type'] === 'image' && $field['value']) { echo '
✅ Image array format - working correctly
'; } elseif (is_numeric($field['value'])) { $image_url = wp_get_attachment_url($field['value']); if ($image_url) { echo '✅ Attachment ID format - working correctly
'; } else { echo '❌ Could not get image URL for attachment ID: ' . esc_html( $field['value'] ) . '
'; } } } echo '';
if ($field['type'] === 'image') {
echo esc_html( '
' );
} else {
echo esc_html( '
' );
}
echo '';
echo 'No ACF fields found for this post.
'; } } private function show_attachment_details($attachment_id) { $attachment = get_post($attachment_id); if (!$attachment || $attachment->post_type !== 'attachment') { echo 'Attachment not found.
'; return; } $url = wp_get_attachment_url($attachment_id); $file_path = get_attached_file($attachment_id); $canto_id = get_post_meta($attachment_id, '_canto_asset_id', true); $canto_data = get_post_meta($attachment_id, '_canto_asset_data', true); echo '| WordPress ID | ' . esc_html( $attachment_id ) . ' |
|---|---|
| Title | ' . esc_html( $attachment->post_title ) . ' |
| MIME Type | ' . esc_html( $attachment->post_mime_type ) . ' |
| URL | ' . esc_url( $url ) . ' |
| File Path | ' . esc_html( $file_path ) . ' |
| File Exists | ' . ( file_exists($file_path) ? '✅ Yes' : '❌ No' ) . ' |
| Canto Asset ID | ' . ( $canto_id ? esc_html( $canto_id ) : 'Not from Canto' ) . ' |
' . esc_html( print_r($canto_data, true) ) . ''; } } private function show_recent_posts_with_acf() { $posts = get_posts(array( 'post_type' => array('post', 'page'), 'posts_per_page' => 10, 'meta_query' => array( array( 'key' => '_', 'value' => 'field_', 'compare' => 'LIKE' ) ) )); if ($posts) { echo '
| ID | Title | Type | Status | Actions |
|---|---|---|---|---|
| ' . esc_html( $post->ID ) . ' | '; echo '' . esc_html( $post->post_title ) . ' | '; echo '' . esc_html( $post->post_type ) . ' | '; echo '' . esc_html( $post->post_status ) . ' | '; echo ''; echo 'Debug '; echo 'Edit '; echo 'View'; echo ' | '; echo '
No posts with ACF fields found.
'; } } } // Initialize the debug admin page new Canto_Debug_Admin();