Title: Use a variable inside get_post_thumbnail
Last modified: August 21, 2016

---

# Use a variable inside get_post_thumbnail

 *  [Jimmydoodaa](https://wordpress.org/support/users/jimmydoodaa/)
 * (@jimmydoodaa)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/use-a-variable-inside-get_post_thumbnail/)
 * I have custom post types, with custom meta fields.
    Used in a loop to list features
   on my homepage.
 * Within the loop, I want to use a variable ($number) from one of my meta fields,
   to pull the feature image from a different post.
 * EG: This works of course, getting the image from post no. 3778 :
 * `<?php echo get_the_post_thumbnail( 3778 , 'thumbnail' ); ?>`
 * but I need the number to be my variable, such as:
 * `<?php echo get_the_post_thumbnail( $number , 'thumbnail' ); ?>`
 * I’ve been at this for 2 days now… PLEASE HELP?!

The topic ‘Use a variable inside get_post_thumbnail’ is closed to new replies.

## Tags

 * [get_post_thumbnail](https://wordpress.org/support/topic-tag/get_post_thumbnail/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 0 replies
 * 1 participant
 * Last reply from: [Jimmydoodaa](https://wordpress.org/support/users/jimmydoodaa/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/use-a-variable-inside-get_post_thumbnail/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
