Function get_children() returns null
-
HI
I created my own theme. I show posts with thumnails of images that are attached to the posts. I use this function:function getTheFirstImage() { $files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image'); if($files) : $keys = array_reverse(array_keys($files)); $j=0; $num = $keys[$j]; $image=wp_get_attachment_image($num, 'large', false); $imagepieces = explode('"', $image); $imagepath = $imagepieces[1]; $thumb=wp_get_attachment_thumb_url($num); echo "<img src='$thumb' class='thumbnail' />"; endif; }
It works corectly. But when I create new post and I use image that is already used in other post, then it doesnt show thumbnail. I checked that in this case function get_children returns null although I have correct post parent ID in this function.
I have no idea how fix this problem.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Function get_children() returns null’ is closed to new replies.