Support » Fixing WordPress » How to get image URL into custom field using wp_insert_post

Viewing 3 replies - 1 through 3 (of 3 total)
  • Update:

    I have been able to get the custom field updated, or at least I think I have. But, is being updated with an empty value.

    Here is the change I have made …

    /insert image
    require_once(ABSPATH . 'wp-admin/includes/admin.php');
    $attachmentId = media_handle_upload('async-upload'); //post id of Client Files page
    update_post_meta($postid, 'thumb', wp_get_attachment_url($attachmentId));

    It appears to me that the original code is not getting the path of the uploaded image. I believe that is one section I have not changed, because as I said, I is not a coder.

    Can anyone give me any suggestions on how to get the image url, so it can be used as the value to go with thumb as a key?

    Seems the code I was copying did not have the post id parameter in the async line, and it did not have the enctype declaration between the form tags.

    Got it working.

    Hi Kirkward,

    If it’s not too much trouble could you paste in the entire working code?
    I’m starting to work on something similar. There are lots of bits and pieces everywhere, but and it’s hard to find a working example of the whole thing, from form fields to finished post.

    Thanks, Ron

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get image URL into custom field using wp_insert_post’ is closed to new replies.