WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I grab a photo, that has been added to a post, and use it elsewhere on a site when there have been several photos added to the post? For example, my site has a blog (Wordpress) and a non-blog section. I want to pull one image from my latest post for use in this non-blog section. Keep in mind that there might be multiple photos associated with the post.

The trick to me seems to be how to designate one specific photo of however many are associated with a post as "the photo" that will be used in the non-blog portion of the site. Ideas? Suggestions?

share|improve this question
You could populate a post meta options field with the name of that photo and then call it elsewhere via the ID of the post get_post_meta($post->ID, .... – kaiser Mar 24 '11 at 6:55
up vote 2 down vote accepted

Well one photo can be assigned as the thumbnail as you can see in the post editor screen. Otherwise as the comment above suggested create a post meta field for example 'my_post_image' and place the id of the image attachment in that field. That is how WordPress saves the post thumbnail (look in the database, something like _post_thumbnail is the meta field name).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.