simple codex/php coding question: get_children
-
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?
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘simple codex/php coding question: get_children’ is closed to new replies.