833 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
+8 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!

1028 posts It's in the pipeline!
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Elite Author: Sold more than $75,000 on Envato Market
  • Sells items exclusively on Envato Market
+7 more
purethemes says
833 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
+8 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 :(

1611 posts Chris Robinson
  • Located in United States
  • Has sold $500,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 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/

741 posts
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 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.

833 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
+8 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