• Hello everyone,

    I need a code to change attachament image, i already have attachament ID. After many search i don’t know how make this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Murilo,

    Give this article a read and see if it answers your question: http://codex.ww.wp.xz.cn/Using_Image_and_File_Attachments#Attachment_to_a_Post

    Thread Starter MuriloR

    (@murilor)

    Hey Micah, ty for post.

    I’m developing a frontend application. I’m using this code to add a attachament:

    require_once(ABSPATH . 'wp-admin/includes/admin.php');
    	$id = media_handle_upload($img_up, $post_id);
    
    	$info = array();
    	$info['ID'] = $id;
    	$info['post_title'] = $post_title;
    	$info['post_excerpt'] = $post_excerpt;
    	$info['post_content'] = $post_content;
    
    	wp_update_post($info);

    Edit all post is easy, but dont know how update only the image via code.

    Thread Starter MuriloR

    (@murilor)

    Someone know how make this? or i need delete the attachment to change the image?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Change attachament image’ is closed to new replies.