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

I need to be able to add a feature image to a post as a link. The link is good, it's green check. And no i cannot upload the file and insert into post dont do anything good. I have the link to the image i just whant feature image to use it. Why i dont what ti upload it, it's because my gallery is completely OUTSIDE awfull WP gallery system ! and work great as this

SO the question is. If my link is : http://www.notreaventure.com/photo-0007/images/_MG_2133.jpg and i like WP to use it as feature image, can i put this link in a custom files, let's say featureimg : http://www.notreaventure.com/photo-0007/images/_MG_2133.jpg, and add a funtion that tell the WP system to get this field and get it to feature image, so nothing will be broken. I just cannot seem to know how to hack wp to get the funtion feature image to get it's image from custom field...

can you help, thanks in advnace

share|improve this question
awfull WP gallery system — why would you say that? I'm hurt ;) — If it's the output HTML that are you are referring to as "aweful", you can easily fix it. wordpress.stackexchange.com/a/43562/10691 – its_me Jul 2 '12 at 4:13
@AahanKrish, sorry to hurt you feeling, but i hurge to find a solution, when i upload a folder of 100-150 images and only tell the system : do a slideshow with it. I cannot find it, so i write it, and work perfectly. Upload the folder and link it to the folder name, that it, no upload, no fancy short code, nothing else. Preloading included. If you know a WordPress plugin that just do that... i will be please to used it right away. Have a look at it : notreaventure.com/photo-0007/gal.php – menardmam Jul 2 '12 at 15:30
up vote 1 down vote accepted

Yes, you've guessed it right. You will need to use Custom Fields in order to define the URL for the Image that you wish to use as Featured Image for the post.

Next part is to tell the Wordpress to use the Image from URL you've in Custom Field as Featured Image. Here, you can use filter called "post_thumbnail_html". The Filter is defined in "wp-includes/post-thumbnail-template.php" file under function "get_the_post_thumbnail" and also available in the latest version of Wordpress.

The definition goes like this:

return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );

Here is a sample use of it:

function custom_post_thumbnail($html)
    return "<img src='https://www.google.co.in/images/srpr/logo3w.png' />";
add_filter('post_thumbnail_html', 'custom_post_thumbnail');

Note that above code snippet is just to give you an idea of how to use this filter. You will need to add required code to get the Custom Field value and return proper IMG tag. The best thing I would suggest to do is merely parse the Image SRC part of $html and replace it with your URL. Also don't forget to check if the Custom Field is empty; in that case, just return the default $html without altering.

I hope this helps.



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.