How to retrieve image from URL and set as featured image post thumbnail

Posted by Prem Tiwari | Updated on

How to retrieve image from URL and set as featured image post thumbnail. My favorite way of handling this problem has been to use a little documented function I discovered on another stack post: media_sideload_image

It works by fetching an image url to the WordPress upload dir and then associating the image to a post’s attachments.

You can try it like so:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers