839 posts
  • Power Elite Author
  • Winner
  • Top Monthly Author
  • Trendsetter
+10 more
wpbakery
says

Hi guys,

Does anyone can share a code snippet, how to get first attached image path inside of the loop in index.php?

Thanks!

1142 posts It's in the pipeline!
  • Top Monthly Author
  • Trendsetter
  • Weekly Top Seller
  • Author Level 11
+9 more
purethemes
says
839 posts
  • Power Elite Author
  • Winner
  • Top Monthly Author
  • Trendsetter
+10 more
wpbakery
says
http://www.phpapi.com/blog/2008/11/03/wordpress-how-to-display-first-attached-image-for-post

Thanks for a quick reply. However I’m having problems :(

$images =& get_children( ‘post_parent=’.$post->ID.’&post_type=attachment&post_mime_type=image’ ); print_r($images);

It seems that it doesn’t populate an array… really strange :(

1680 posts Chris Robinson
  • Elite Author
  • Author Level 10
  • 7 Years of Membership
  • United States
+13 more
contempoinc
says

Take a look at Jeff Starr’s post on displaying Image Attachments:

http://digwp.com/2009/08/awesome-image-attachment-recipes-for-wordpress/

743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 more
Orbital_Themes
says

I use this snippet (http://pastie.org/595002) and it works great. Can’t remember where I’ve found it.

2541 posts
  • Affiliate Level 2
  • Author Level 2
  • Collector Level 3
  • Podster
+8 more
CreatingDrew
says

Take a look at WordPress for Designers Day 17, we deal with using attachments within the loop and how to display them.

839 posts
  • Power Elite Author
  • Winner
  • Top Monthly Author
  • Trendsetter
+10 more
wpbakery
says

Thank you guys for the links!

I’ve figured out my problem, I was uploading photo, but I didn’t press the save changes button, so Image was uploaded but haven’t been associated with the post. Silly me…

by
by
by
by
by
by