Permalink on ACF image |

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…


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer