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]
- Can I exclude a post by meta key using pre_get_posts function?
- What is the index [0] for on post meta fields?
- Add custom field to the archive page?
- Matching Serialized Arrays with meta_query
- So much data in postmeta
- How to hide meta box values from custom fields list?
- How do I make a custom field choose an image?
- get_post_meta() unserialize issue – returns boolean(false)
- What is the advantage of the wp_options design pattern?
- Unable to get Preview of Uploaded image within a Custom Meta box
- Meta keywords and descriptions plugin for manually editing meta for each page/post
- Up/Down voting system for WordPress
- Change content before writing to database
- post meta data clearing on autosave
- Order Custom post type loop by custom field (datepicker)
- How to get source of custom meta image?
- Update meta values with AJAX
- Custom fields to save multiple values
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Metabox with multiple fields added by user and upload box
- Login & Register & Custom details WITHOUT plugin
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- Saving custom image meta fields
- Get all meta keys assigned to a post type
- Update posts after populating ACF field value [closed]
- WP Custom Fields Metabox Disappears – ACF plugin issue [closed]
- Transfer self made functions.php custom fields to Advanced Custom Fields [closed]
- Adding custom fields (post meta) before/during wp_insert_post()
- How to query posts with certain custom meta data, and output Post data
- Will loading too many ACF Fields cause slow down?
- post meta getting deleted on save
- Custom field not updating when value is empty
- meta_compare seems to be treating values as strings instead of integers as expected
- Calling the “wp-link-wrap” pop-up modal
- Add post meta fields, when creating a post using WordPress’ REST API
- Store array as single, serialized post meta field or many post meta fields?
- Custom Field Values not updating unless I click “Update” twice
- Get an advanced custom field after post publish
- How to create a dropdown select of all items in an ACF field group
- How do I add an image upload, custom field to a WooCommerce product?
- update_post_meta for repeated custom field [closed]
- Trying to update_post_meta function
- get_posts in meta box dropdown not showing latest posts
- Display Custom Meta Box Field Only If Value is Present
- Ordering posts by custom field named “date” in backend
- Custom fields issue [closed]
- How to copy data from a custom field to the post_content?
- change order of images attached to post
- how can I show name and value of Custom Fields together?
- Display custom field from the front page on another page
- Custom field as featured image caption
- Gravity Forms Update post meta from template [closed]
- The conditional logic only works to show or hide?
- How can I add/update post meta in a admin menu page?
- custom filed from post in the side bar
- Unable to select image with custom field
- Rewrite comment form post ID on submit
- What am I missing in this Code Block?
- How to show ACF fields in Gridbuilder custom block
- Shortcode for Custom Field of Media Attachment (to use with Featured Images)
- SQL query to change the value of a Custom Field
- Custom meta POST request fired twice when updating a post in Gutenberg
- Retrive acf fields in publish_post action for wp_mail
- Add custom field information to source meta data
- Update custom field on page specific to logged in user
- Create Meta boxes dynamically
- List sub pages with custom field content converting image ID to URL
- Delete custom meta
- WordPress taxonomy child image
- Filter and display a specific custom field value [closed]
- wordpress simple post multi rating with post_meta and user_meta
- Query Posts Via WordPress URL
- wp_postmeta are updated for only one page
- Upload image to wordpress
- I want to add a custom field in the rss title of each post, but don’t want it to be shown on the site
- Custom fields / meta box output
- Get single image from custom fields made with WCK custom fields creator
- Colecting values from custom field checkboxes and displaying them in the post
- Build Array from Input Fields question
- How can i put a custom field inside this php
- Site uses wpdb to fetch meta_keys but just displays first meta_key from a page (the post uses the same meta_key “filmmaker” more than once)
- Truncating characters in Advanced Custom Fields works some places but not others?
- Conditional display based on ACF checkbox
- How to add an ACF only for parent term?