Title: [Plugin: Multiple Post Thumbnails] Assign Post Thumbnail URL to Variable
Last modified: August 19, 2016

---

# [Plugin: Multiple Post Thumbnails] Assign Post Thumbnail URL to Variable

 *  [onedavid](https://wordpress.org/support/users/onedavid/)
 * (@onedavid)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/)
 * Hi all,
    Is it possible to pass the thumbnail URL to a variable rather than output
   the image tag? Please excuse my PHP ignorance.
 * Thanks! -D

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Chris Scott](https://wordpress.org/support/users/chrisscott/)
 * (@chrisscott)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/#post-1751659)
 * You can use `MultiPostThumbnails::get_the_post_thumbnail()` and pass in the same
   arguments you would to `MultiPostThumbnails::the_post_thumbnail()`. That won’t
   echo it so you can assign it to a variable.
 *  [whatadewitt](https://wordpress.org/support/users/whatadewitt/)
 * (@whatadewitt)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/#post-1751667)
 * Hi Chris,
 * The plugin is awesome, but when I use get_the_post_thumbnail() I still get all
   of the associated “img” tag, where all I am looking for is the URL to the image…
   Is this what should be happening? Surely I can parse it, but wanted to make you
   aware.
 * WP 3.0.1
 * Thanks,
 * –d
 *  Plugin Author [Chris Scott](https://wordpress.org/support/users/chrisscott/)
 * (@chrisscott)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/#post-1751670)
 * Sorry, this should work:
 *     ```
       $post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id($post_type, $thumb_id, $post_id);
       wp_get_attachment_url($post_thumbnail_id);
       ```
   
 * where the args to get_post_thumbnail_id are the same you’d pass into `MultiPostThumbnails::
   the_post_thumbnail()`
 *  [sheyes@s-heyes.com](https://wordpress.org/support/users/sheyess-heyescom/)
 * (@sheyess-heyescom)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/#post-1751676)
 * Chirs, I really need your help! 🙂 Ive been pulling my hair out all evening 🙁
   its 2am and still no solution
 * I’ve NO idea how to implement the code you provided.
 * I use the following code to check if theres a thumbnail called four-image, if
   there is, it shows the thumbnail…
 *     ```
       <?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'four-image')) { ?>
   
       <a href="#?color=Orange" onclick="switchImg('#')"><?php MultiPostThumbnails::the_post_thumbnail('post', 'four-image', NULL, 'four-image-thumnail'); ?></a>
   
       <?php } ?>
       ```
   
 * But I also need to be able to call the url of the thumb and insert that into 
   the (‘#’). The reason for this is so when the user clicks the link it changes
   the main image on my page. [http://www.wrapsodyscarves.com.php5-18.websitetestlink.com/pashmina/fuax-fur-stole/](http://www.wrapsodyscarves.com.php5-18.websitetestlink.com/pashmina/fuax-fur-stole/)
 * Please help
 *  [yetimade2](https://wordpress.org/support/users/yetimade2/)
 * (@yetimade2)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/#post-1751758)
 * Chris,
 * This plugin seems really great, but after following the instructions posted in
   the Installation and FAQ section of the plugin page on WordPress.com, it’s still
   not working. I am using the code exactly as it is written in those instances;
   also, I’ve reviewed the other support topics related to this plugin and have 
   found no success. Is there something that I’m missing?
 * Thanks,
    JC

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[Plugin: Multiple Post Thumbnails] Assign Post Thumbnail URL to Variable’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/multiple-post-thumbnails_d94965.svg)
 * [Multiple Post Thumbnails](https://wordpress.org/plugins/multiple-post-thumbnails/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multiple-post-thumbnails/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multiple-post-thumbnails/)
 * [Active Topics](https://wordpress.org/support/plugin/multiple-post-thumbnails/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multiple-post-thumbnails/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multiple-post-thumbnails/reviews/)

 * 5 replies
 * 5 participants
 * Last reply from: [yetimade2](https://wordpress.org/support/users/yetimade2/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-assign-post-thumbnail-url-to-variable/#post-1751758)
 * Status: not resolved