ACF ‘Image’ Field Returns NULL
-
Greetings and Happy New Year.
I have the Advanced Custom Fields WordPress plugin free version, version number 5.9.3 and created a custom field group. It contains a “Tab” type custom field labeled “Overview and has a “Group” field within it labeled “Basics”. “Basics” group contains “Tab” field labeled “Images”. Inside the “Images” sub field are three “Image” type custom fields, each returning an “Image Array”.
For example, the first image field has the field name “product_image_01”. All of its remaining field descriptors are at their default values. The ACF custom field group itself is assigned to a custom post type for which I created a custom post type template. Here is the code in question for the custom post type template.
<?php $product_image_01 = get_field("product_image_01"); var_dump($product_image_01); ?> <img src="<?php $product_image_01; ?>" />
The “var_dump” function returns NULL, even though I assigned an image to the custom post that is associated with the custom post type to which the ACF custom field group is assigned. I received a NULL return despite the image return type (array, url, id).
I also separately tried the following as a test, although I do not see why it would be necessary to associate a product image with a WP user:
<?php $author_id = get_the_author_meta('ID'); $author_pi_01 = get_field('product_image_01', 'user_' . $author_id); echo $author_pi_01; ?>
This did not work either. In fact, it returned no response at all.
Thus far, I was able successfully to return data from a variety of other ACF custom field types (text, url, text area, range, select, number) defined elsewhere under the “Basics” group. I only have a problem with the ACF ‘Image” field type.
I would appreciate guidance on returning an image result in this scenario. Thank you.
- The topic ‘ACF ‘Image’ Field Returns NULL’ is closed to new replies.