I'm trying to call the WP database to get the links for all images attached to a given post. Here's my code, but it is going into the if statement (no attachments), rather than the else statement (with attachments).
What am I doing wrong?
$attachedimages =& get_children('post_type=attachment&post_mime_type=image');
if ( empty($attachedimages) ) {
// no attachments here
print "<!-- no attached -->";
} else {
foreach ( $attachedimages as $attachment_id => $attachment ) {
print "\n" . '<meta property="og:image" content="' . wp_get_attachment_image( $attachment_id, 'full' ) . '"/>';
}
}
Any ideas?