How to get featured image link url?

Hi guys I have been trying to get the set the featured image url but it I can only link to the post itself or to the image itself, when I add featured image on the link URL I add a different link but it doesnt work is there a way I can add different link on the featured image and then retrieve this link on the code? so it would be something like

<a href=“<?php link_url(); ?>”><?php the_post_thumbnail(‘medium’); ?></a>

This depends on whether you want to get the featured image for the individual post or for multiple posts (for example on a blog index page).

For a single post you can just use the function get the post thumbnail which you can read about in the Wordpress Codex here.

You also need to first enable featured images in your wordpress theme if you’re starting from scratch or your theme isn’t currently ‘featured post’ enabled. You can do this by putting:

add_theme_support( 'post-thumbnails' );

in your functions.php file

But basically something like this should work:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> //This is your loop starting, it is used in most Wordpress themes.

if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.

<?php endwhile; endif; ?> //This is your loop ending. 

Looking at the codex link above you’ll also find you’re able to specify sizes.

Hope this helps.

Hi the featured image display fine what I am trying to do is link the featured image to something else, when you upload the image the upload box theres is the Link URL,so I had to link to a another website but it doesnt link? or even save teh Link URL is it only possible to link to image path or the page itself??