voceconnect / multi-post-thumbnails

Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
143 stars 63 forks source link

How do I get the URL only? get_the_post_thumbnail_url throws an error. #118

Closed s3w47m88 closed 7 years ago

s3w47m88 commented 7 years ago

Hi, I am trying to get just the URL but when I use get_the_post_thumbnail_url I get an error. Any thoughts? Thanks!

chrisscott commented 7 years ago

Can you share the code you are using to do this?

s3w47m88 commented 7 years ago

I don't have the code anymore, but I was trying to use get_the_post_thumbnail_url to wrap:

<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail( get_post_type(), 'secondary-image' ); endif; ?>

So that I could extract the URL instead of getting the whole Object. But it simply didn't work. I believed this because get_the_post_thumbnail worked, but get_the_post_thumbnail_url did not. And I think that's because they require different arguments, that latter requiring arguments that the above Class and Function don't pass, thus making it impossible to get the URL using that Function.

Does that make sense?

Thanks for your time!

chrisscott commented 7 years ago

The first 4 args of get_post_thumbnail_url() are the same as the_post_thumbnail() so it should have worked.