If you use Post Object field type, then it is stored as ID in custom field. So this should do the trick:
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'meta_key' => '<FIELD_NAME>',
'meta_value' => <POST_ID>
));
PS. You should use ‘posts_per_page’ instead of ‘numberposts’ (which is deprecated).
Related Posts:
- How to update custom fields using the wp_insert_post() function?
- Make custom field meta not display if there is not data in it
- How can I add extra word in permalink when someone click download button?
- Which PHP page is the Default Posts Page
- WP_Query: getting posts where custom field exists
- Unable to render custom field after attempt to generate a list of recent post in page template
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Query on a repeater date (acf)
- When working with a post, almost all wp_postmeta are deleted
- Posts sortable column not sorting properly for custom field numbers
- Update all posts automatically when using post_meta
- Display posts by month
- Custom SQL query to get List of posts with featured image url
- How to display multiple Post meta_key/meta_values by SQL query
- How to make an meta_query optional?
- get_the_content if it contains multiple lines it results in SyntaxError
- Looking to exclude blog posts from category Previous/Next buttons
- How can update custom meta for all posts
- Automatic Excerpt Not Working
- Unique key for each row in a repeater field
- Using a javascript file to access a get posts array
- How is WordPress manipulating the posts like there are folders?
- Trying to make php run in a post
- Remove posts after a given amount of time
- Hide wordpress field if data is empty in post!
- How can I create a list of page titles from custom meta values?
- How to show part of the_content?
- How to set a min number of words for a blog post
- Get post id in a function when edit/add a post
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- How to use thumbnail size of image if I’m only using src to get image
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Trying to retrieve post meta
- Redirect to another page using contact form 7? [closed]
- Advanced Custom Fields – display label and value only if value entered
- Pagination on Custom Post
- $wpdb returns duplicate posts
- Update post title from external file?
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- if custom field doesn’t exist, use post thumbnail instead, as image background
- How to use mysql LIKE with wpdb?
- How to store multiple custom meta box
- Do I need to edit my theme in order to change the title of my blog page?
- Add new post in existing categories using wp_insert_post
- How do I add more options to the post-new.php page?
- Get the id of all images in a post
- Do not duplicate posts with multiple categories in multiple loops
- Four posts per row [closed]
- Need help removing […] after excerpt
- Define category ID using get_post_meta
- WordPress Search
- Adding custom url to readmore link using get_permalink()
- Display movies that apear this day next
- Add “alt” Attribute to GD Star Rating Tags
- custom header text
- Add custom fields from different posts
- Pagination in single.php
- Edit and delete permissions pages and posts
- Order category posts by last word of custom field
- Post form – AJAX won’t upload featured image – Plugin development
- Block error message in foreach loop when looping through ACF field
- How to get post image caption by index
- Is there anyway I can call the year once?
- Check $post->ID against multiple values
- Posts missing on author page
- How to allow users to save list of posts in wordpress?
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- How to center all text body in single.php at once?
- LinkedIn Share Post Button
- Get current_post in reverse order with pagination
- How to display custom field from a gallery thumbnail?
- How do I generate formatted permalinks as specified in backend options?
- Getting a value from a custom field from a page that shares a parent with the current page
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Basic PHP question (displaying post title over thumbnail) [closed]
- Post from front end form to post_meta
- media_handle_sideload() returned post_id being incremented
- Saving Post redirects to 404 page when php $_GET variable in post body
- If custom field doesn’t exist, or exists and it’s true show title?
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Outputting a custom field in PHP
- Custom fields randomly stop working
- Where can I find the code for the menu page meta boxes?
- How to echo a different field if another field is empty?
- PHP Puzzle: Unique Styles with PHP loop
- link to page_for_posts
- How to create a loop that will display one post and stop?
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- Add multiple HTML attributes to an Elementor button
- How to create a WordPress PAGE in another folder?
- How do I get a function to work in single.php
- I want to show image from custom field image on my custom page template
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- Count the number of matching post names in foreach loop
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
- ACF number less than comparison not working