I am referring to this codex, https://codex.wordpress.org/Function_Reference/media_handle_upload

There I can attach the uploaded image to the post as attachments by this :

$attachment_id = media_handle_upload( 'my_image_upload', $_POST['post_id'] );

But, I want to just get the url of the uploaded image, without adding the image as the post attachments.

How can I get that uploaded image url ?


You can get it with:


More info in the codex

In your example:

$attachment_id = media_handle_upload( 'my_image_upload', $_POST['post_id'] );
$attachment_url = wp_get_attachment_url($attachment_id);
echo $attachment_url; 
| improve this answer | |
  • Hi, I don't want to add it as attachments to the post. – hkchakladar Aug 21 '15 at 7:00
  • I edited my answer. Hope this helps. – amespower Aug 21 '15 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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