|Reported by:||reliability||Owned by:|
I've tried to find similar tickets but was unsuccessful. So, I apologize if this is a duplicate.
Consider the following steps:
- Upload an image A to the media library.
- Create a new post P1 and insert the image A.
- Create another post P2 and insert the image A.
The post_parent property of A will be set to the id of P1. But when adding the image to the post P2, no new post-entry for A with the post_parent-id of P2 is added to the wp_posts-table.
The effect of this is, while the image is properly displayed when the content of post P2 is rendered, code that retrieves images that are attached to P2 fails. For instance:
/* ... */ $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image' ) ); /* ... */