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?
- Customizing HTML Editor Quicktags button to open a dialog for choosing insert options
- Hook that get’s triggered when the author of a post is changed
- Allow user to “edit_others_posts” to save only, not publish
- The hook for the AJAX Add to Cart button?
- Let private posts stay in status “private” after edit through “editors”
- Add existing images from Media Library in to custom gallery
- Replace image attributes for lazyload plugin (data-src)
- How to create WP Editor using javascript
- How do I detach images from posts?
- How do I sort (order) the results from `get_children()`?
- upload image in a meta box
- Restrict access to post if it is currently being edited
- How can I allow editors to leave comments on posts that have not yet been published?
- Alter image output in content
- Get post embedded image caption
- Filter/Remove HTML Elements on all posts and pages
- First hook to use current page post id
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- How to place HTML below the title of the (custom) post overview
- Post taxonomy from exif data
- Getting post id from wp_insert_post_data function?
- get custom image size
- how to replace embedded “full” sized images within a post with the “large” ones
- How can I remove posts of a certain category from homepage after a specified time period?
- Batch process: remove first image from post content
- Modify WP_Post before processing
- WordPress version 3.8 – Preview button not working for editor
- Show featured image next to post-teasers in Genesis Framework?
- How to modify post content?
- Is there any action/filter hook to use when an image gets edited in the editor?
- Adding buttons to Add New Post and Add New Page
- Default to ‘all’ view on the ‘edit-post’ screen for authors
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- Show only posts with images and a fixed amount of posts
- How would one change the default url structure of attachments?
- If statement to check if post has image
- Gather posts into a cart/lightbox and share with another user
- How to dynamically parse and transform post/page content before displaying it?
- Is it possible to filter the main loop to exclude posts from a specific category?
- 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
- Uploading images in custom post form
- Make insterted image point to post url instead of attachment page
- how to give multiple post thumbnails to a post
- How to allow multiple thumbnail upload for Posts?
- get_children returns older images
- How to display post title inside thumbnail?
- How to remove text and retain in caption image using the_content function
- How to get all inline images in post content? [duplicate]
- Exists filter or action that change Add New Post link?
- Link post images to post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- how can display a post on home screen without images
- any way to access variables from within post editor?
- How to exclude native lazy loading from first image in post content?
- Embedding Post Editor Into External Site
- How can I change the date format of the revision list?
- How to get title of images in post content
- the wp_post_update isn’t working all the time
- Pinterest button shows image options from different posts
- Change the size of the featured image for post?
- Is update_post_meta used when save_post action hook is invoked?
- how to filter posts by category without page load (ajax) in wordpress?
- Remove status ‘archived’ from the default post and page view
- How to prevent post update using transition_post_status
- Dropdown Select Post Filter
- long-title posts do not want published
- Blog images not showing on homepage
- How do i search post by jquery datepicker?
- show only one category and filter by tag
- Prevent WordPress from putting around specific element
- how to create other sizes of original image in one go wordpress uploads
- Filter question list on substring of metavalue
- Add review box by function at top or bottom of content
- Stop images from being displayed on the front-end of the site
- Get results from the main wp_query
- How might one programmatically set the link for all images in all posts?
- Relative Image Urls in Posts are starting from root – Not from WordPress Address (URL) at General Settings
- fire action when post is being edited as well as saved?
- Post thumbnail height problem
- website images getting corrupt automatically
- Optimize blog that serves hundred of images and videos