[ad_1]
Hello,
Thanks for your fantastic plugin.
I would like to place an image ACF field with automatically the post permalink on it.
I read the documentation, asked an AI and tried this code :
add_filter('meta_field_block_get_acf_field', function ($content, $field_name, $post_id) {
if ($field_name === 'logo_presse') {
$image_id = get_field($field_name, $post_id);
if ($image_id) {
$image_url = wp_get_attachment_image_url($image_id, 'full');
$permalink = get_permalink($post_id);
$content="<a href="" . esc_url($permalink) . '"><img src="' . esc_url($image_url) . '" alt=""></a>';
}
}
return $content;
}, 20, 3);I am sure of the field name, I choosedd “ID” in ACF field image, The image displays all right but no link.
Any help welcome…
Cheers
