Multiple loop working, function inside isn’t
-
Hi all, I’m using this piece of code I found (http://impnerd.com/wordpress-hack-add-post-images-to-your-homepage) to display the first image uploaded to a post on the homepage next to the excerpts of posts. I’m doing this outside the main loop on the homepage, and have been having problems. When I do rewind_posts() to get the same loop results, it works fine, but when I try to create a different loop, this code snippet breaks down:
<?php $images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . $post->ID ); if ($images) { $keys = array_keys($images); $num = $keys[0]; $firstImageSrc = wp_get_attachment_thumb_url($num); echo "<li><img src=\"{$firstImageSrc}\" width=\"288\" height=\"216\" alt=\"\" title=\"\" /></li>";} ?>I have tried the methods in The_Loop#Multiple_Loops_in_Action in the docs, and they work, meaning I can get normal output after the loop, but my snippet above doesn’t work. Any idea if there is a conflicting method call or something that’s going on that’s stopping it from working? Would appreciate some help, thanks!
The topic ‘Multiple loop working, function inside isn’t’ is closed to new replies.