This should work within your function:
get_post_field( 'post_parent', $id )
Related Posts:
- Get old values for post before saving new ones
- how to limit edit_form_after_title hook to page and post edit only?
- how to display post content without post image?
- Filter post before *editing*
- Custom function for “Submit for Review” hook
- How can i do something after head like adding a hook for after head but before post
- Modify Image Source With The_Content Filter?
- What is the filter or hook to add admin controls to posts on the front end?
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Trying to alter the post_content through the_post
- Adding bootstrap classes to video shortcodes
- preg_replace not removed “class”
- Modify posts listing at back end
- Hook for changing excerpt content when excerpt not set
- Is it possible to add a shortcode below post title?
- Rewrite image links from attachment id to attachment link
- Restricting displayed posts to posts from only select authors
- How to get the postID inside ‘content_save_pre’? Other hook?
- Modify upload directory to use post category slug in file path on multisite installation
- wp-cli post create & media import issues
- How to filter my search in post if contains a word in title, content or excerpt?
- More then one menu items are assigned with “current-menu-item” class
- Update post_content everytime a custom post is opened in backend
- How to access $post from a callback function
- How to filter the image embed code based on link type
- Updating post data on save (save_post vs wp_insert_post_data)
- Lost draft under all posts and drafts
- Posts and Attachments with “Published” status in Search
- Get attachments for posts that belongs to a specific category
- List all categories with featured image from post?
- Add custom text in the media library image meta area
- Get all images in post and comments like Twitter before post title
- How to allow visitors to filter posts by multiple taxonomies
- Show only posts with images and a fixed amount of posts
- Issue where WP Featured Image will not display
- Copy post to separate database with “add_action(….)”
- How would one change the default url structure of attachments?
- Hooking into the post editing screen for an existing page only
- Redirect to another page using contact form 7? [closed]
- If statement to check if post has image
- Gather posts into a cart/lightbox and share with another user
- Call Web Services on post first publish
- add to end of post in the loop with plugin
- Thumbnail Image to go in the post aswell
- Add filter to the end of the post
- How to dynamically parse and transform post/page content before displaying it?
- Remove Featured Image & All Media Uploaded to the Post
- Get post content with all filters applied, knowing post id
- What does WordPress do if I save a post without content/title? [duplicate]
- Is it possible to filter the main loop to exclude posts from a specific category?
- What are the benefits of setting a “featured image” for a WP blog post?
- query post limits
- update image path with words starting uppercase to lowercase chars
- why the same code got different results when using query_posts in functions.php and index.php
- Divs appearing everywhere in post content
- WP text styles not coming through to actual post
- How to only publish posts with image in it
- Uploading images in custom post form
- Filtering posts on Post Administration Page by Week Number instead of by Month
- Upload attachment from external site
- WordPress.com post editor replacement
- Make insterted image point to post url instead of attachment page
- Prevent posts with certain post_meta to be edited
- Get URL from all images in a post
- Change the default blog post post attribute template name from “default template” to something else
- Disable posts generated from image uploads
- how to give multiple post thumbnails to a post
- Post filtering is returning blank page
- Posts page not showing correct image
- Images showing up in Post Editor, but not in Published Post
- How to allow multiple thumbnail upload for Posts?
- Why can’t publish posts with too much text?
- Automatically set post_parent value
- Image behind the post’s title
- get_children returns older images
- How to display post title inside thumbnail?
- Updating permalink structure using ‘post_link’ filter results in 404 error for posts
- How include css class based on post ( in loop ) slug?
- How to remove text and retain in caption image using the_content function
- How to retrieve certain number of images from a wordpress post?
- Restrict displaying posts to the poster itself (in Back-end)
- Show more than 200 images in one post
- How to get all inline images in post content? [duplicate]
- Hide thumbnail if there is a gallery on the post
- Exists filter or action that change Add New Post link?
- Image on rss feed on post
- Change the background of each post according to the category
- How to Featured content with images in home page?
- Where to insert the other site image url for our wordpress post
- select post preview image from nextgen gallery
- How to show a featured image inside a post in only 1 single category
- Inserting Media to WordPress Posts
- Author Avatar as default first image
- Link post images to post
- How to get the next and previous image title from attachment or gallery?
- Attachment image single page
- How to change the order of elements within a post?
- Only show featured image on exerpt and exclude images in post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- changing parent_id on post