Support

Account

Home Forums Backend Issues (wp-admin) Image field not load the value in wp-admin

Helping

Image field not load the value in wp-admin

  • Dear,
    I have a custom Post “fotografia” with some field made using ACF, one of this is an Image, it is mandatory.
    When I edit the post, the field Image is empty and I have to choose every time the image from the media gallery (where correctly I see only the image uploaded to that post) before save.

    I don’t know if matter but I use this function to set the image uploaded as default image of the post, I found the function on the support forum:

    function acf_set_featured_image( $value, $post_id, $field  ){
        if($value != ''){
    	    //Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	    update_post_meta($post_id, '_thumbnail_id', $value,true);
        }
        return $value;
    }
    add_filter('acf/update_value/name=fotografia', 'acf_set_featured_image', 10, 3);
    
    

    The Image field is configured to store as ID.

  • add_filter('acf/update_value/name=fotografia', 'acf_set_featured_image', 10, 3);

    The fotografia should be the name of your ACF image field and it should return the image ID.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.