838 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Became a Top 20 Author of the Month
  • Had an item that was trending
+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!

1140 posts It's in the pipeline!
  • Became a Top 20 Author of the Month
  • Had an item that was trending
  • Had an item that became a weekly top seller
  • Has sold $750,000+ on Envato Market
+9 more
purethemes
says
838 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Became a Top 20 Author of the Month
  • Had an item that was trending
+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 :(

1665 posts Chris Robinson
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Located in 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: Sold more than $75,000 on Envato Market
  • Had an item that became a weekly top seller
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
+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
  • Has referred 10+ members
  • Has sold $100+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Located in United States
+9 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.

838 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Became a Top 20 Author of the Month
  • Had an item that was trending
+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