Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#24790 closed defect (bug) (invalid)

Attachment of posts not working

Reported by: rajd9898's profile rajd9898 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.2
Component: Post Thumbnails Keywords:
Focuses: Cc:

Description

$arrImages =& get_children('post_type=attachment&post_mime_type=image&post_id=' . $lnumber );
		foreach ( $arrImages as $attachment_id => $attachment ) {
			if ($counter <= $imgnum) {
				$image_attributes = wp_get_attachment_image_src( $attachment_id, 'medium' );			
				$output .= '<div class="gallwidg" >' .  wp_get_attachment_image( $attachment_id, 'medium' ) . '</div>';
				$counter++;
			}
		}

this is a code to fetch images inserted in post. But some how this is not working properly with 3.5.2 and 3.5.1 version of wordpress.
Attachment working fine with 3.5 version of wordpress

Change History (1)

#1 @markoheijnen
10 years ago

  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Severity changed from critical to normal
  • Status changed from new to closed

This doesn't seem right. When you query on the post_type 'attachment', you need to set post_status argument to 'inherit' or 'any'. Also post_id isn't an argument for get_children(). Maybe that can be why it goes wrong.

Looking to the code it unlikely a bug in WordPress since it relies on get_posts/WP_Query to get the data. This should then also fail in the backend like the media screen.

Note: See TracTickets for help on using tickets.