I have already read https://stackoverflow.com/questions/41524931/how-to-set-featured-image-programmatically-from-url and that's not the answer to my question.

The above answer will download the image from the source and upload the library. I just want to set external URL(image URL) as the featured image without downloading my own server.

1 Answer 1


You can use the post_thumbnail_html filter to set the post thumbnail programmatically to an external URL.

Then you wold set the image URL in a Custom Field on the post writing screen metabox (in this example with a meta key of thumbnail_url):

add_filter('post_thumbnail_html', 'custom_thumbnail_tag_filter', 10, 3);
function custom_thumbnail_tag_filter($html, $postid, $thumbnailid) {
    if (!$thumbnailid) {
        $src = get_post_meta($postid, 'thumbnail_url', true);
        if ($src) {$html = "<img src='" . $src . "'>";}
    return $html;
  • Thanks, I didn't test, but this is exactly what I need. I will accept after testing it. Commented Jul 4, 2019 at 10:37
  • It should be fine so long as the theme / template uses standard thumbnail functions (some theme's write and use their own.)
    – majick
    Commented Jul 4, 2019 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.