An example with a link. $image_post = get_post( $image_id );: The get_post() function is a core WordPress function that retrieves a post object based on its ID. In WordPress, images in the Media Library are treated as a custom post type called 'attachment'.