see documentation for get_field. change:
$attachment_id = get_field('image');
to pass the post ID as second argument:
$attachment_id = get_field('image', 299);
or:
$attachment_id = get_field('image', $my_id);
Related Posts:
- Display info from custom fields in all images’ HTML
- get_post_meta fields don’t show up on posts page
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- copy attachments to another post type and change attachment url
- Copying Custom Meta Values from existing post to a duplicate post
- Get a post_id where meta_value equals something in a serialized meta_value field
- Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
- ACF: How to get the full field name (meta_key) by a field key?
- Add new image block, set default class name and update it using Javascript
- Get all the posts where meta field with multiple choice has several values checked
- WordPress creates new lines in postmeta table on post update
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- How to delete attachments associated with custom field type when post property changes? [closed]
- Query Posts based on custom field value
- Add image custom attribute [closed]
- save all acf options in one meta_value [closed]
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- Can I exclude a post by meta key using pre_get_posts function?
- Where are custom field values stored in the database
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Difference between meta keys with _ and without _ [duplicate]
- Remove Dimension from wp_get_attachment_image
- Orderby meta_value only returns posts that have existing meta_key
- What is the index [0] for on post meta fields?
- What is “meta_input” parameter in wp_insert_post() used for?
- How to enable revisions for post meta data?
- The “_encloseme” Meta-Key Conundrum
- Best way to programmatically remove a category/term from a post
- Using get_post_meta with new_to_publish
- Advanced Custom Fields – Get custom fields from parent page
- Add custom field to the archive page?
- Matching Serialized Arrays with meta_query
- Custom field metabox not showing in back-end
- So much data in postmeta
- Can I count the number of users matching a value in a multiple value key?
- How to position a custom field before the editor
- When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
- How to hide meta box values from custom fields list?
- Auto sort the wp-admin post list by a meta key
- Change wp_get_attachment_image attributes (src and srcset) on specific custom field
- How do I make a custom field choose an image?
- get_post_meta() unserialize issue – returns boolean(false)
- Display post_object content using Advanced Custom Fields plugin
- What is the advantage of the wp_options design pattern?
- Remove old custom field after import
- Storing meta fields multiple times OR once with multi dimensional array?
- Unable to get Preview of Uploaded image within a Custom Meta box
- Allow user to create instances of custom field
- display specific custom fields
- Extend WP Customizer to make multiple image selection possible
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- Add multiple images to a page sidebar
- Meta keywords and descriptions plugin for manually editing meta for each page/post
- Retrieve custom fields on Categories, using WP-API
- passing argument to get_template_part() or a better way to code
- Is it possible to store arrays in a custom field?
- Get updated meta data after save_post hook
- Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
- Save HTML formatted data to post meta using add_post_meta()
- importing data from non-wordpress mysql db
- Order by custom field date?
- Display thumbnail from custom field
- Add custom field to image editor
- Create meta boxes that don’t show in custom fields
- Transients vs CRON +Custom Fields: Caching Data Per Post
- Unable to save datetime custom meta field using update_post_meta() function
- Up/Down voting system for WordPress
- Change content before writing to database
- post meta data clearing on autosave
- Create custom field on post draft or publish?
- Order Custom post type loop by custom field (datepicker)
- Ordering posts by anniversary using only day and month
- How to get source of custom meta image?
- Using Custom Function With Advanced Custom Fields
- Update meta values with AJAX
- How to break meta values into different items and avoid duplicates?
- Cannot edit post meta fields with rest API
- limit amount of photos uploaded per cpt post
- ajax delete value from custom field array
- Problem with adding exta field in metabox in custom post type
- Save attachment custom fields on front end
- How to use pagination with get_post_meta
- Add a post meta key and value only if it does not exist on the post
- Move value of one custom field to another
- Order posts according to user defined order for meta values?
- Calculate the sum of certain the_sub_fields
- Displaying posts with only upcoming dates according their custom field date value
- Displaying Custom Fields on Post with Genesis Child Theme
- Custom fields to save multiple values
- Custom fields: In what order are they saved into the DB?
- Function to change meta value in database for each post
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Metabox with multiple fields added by user and upload box
- Get aggregate list of all custom fields for entire blog
- Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
- Login & Register & Custom details WITHOUT plugin
- Custom field value based on other custom field values
- Send Multiple Custom Field Values Through the URL
- wp_handle_upload error “Specified file failed upload test” but still creates attachment?