Ondersteuning » Code oplossingen gezocht » Updaten van attachment description

  • Opgelost merren

    (@merren)


    Hallo,

    Ik moet in frontend attachments kunnen wijzigen van title of description..

    $postinfo = array(
    	'guid' => $uploadedfile,
    	'post_mime_type'	=> $filetype['type'],
    	'post_title'		=> $post->post_title . ' employee photograph',
    	'post_content'	=> $mycontent,
    	'post_status'	=> 'inherit',
    );
    $filename = $attachment['file'];
    $attach_id = wp_insert_attachment( $postinfo, $filename, $postid );
    
    // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
    require_once( $_SERVER['DOCUMENT_ROOT']  . '/wp-admin/includes/image.php' );
    
    $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
    wp_update_attachment_metadata( $attach_id,  $attach_data );

    Echter, hij blijft nu nieuwe thumbnails aanmaken IPV de huidige up te daten???

2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)
  • Thread starter merren

    (@merren)

    $myattachid = $_POST["myattachid"];
    $mycontent = $_POST["mycontent"];
    $mytitle = $_POST["mytitle"];
    
    $postinfo = array(
    	'post_title'		=> $mytitle,
    	'post_content'	=> $mycontent
    );
    
    wp_update_attachment_metadata( $myattachid, $postinfo );

    Werkt ook niet 🙁

    Thread starter merren

    (@merren)

    Gewoon benaderen als post!

    $myattachid = $_POST["myattachid"];
    $mycontent = $_POST["mycontent"];
    $mytitle = $_POST["mytitle"];
    
    $postinfo = array(
    	'ID'           => $myattachid,
    	'post_title'		=> $mytitle,
    	'post_content'	=> $mycontent,
    	'post_name' => '' // slug will be generated by WP based on post title
    
    );
    
    // Update the post into the database
    wp_update_post( $postinfo );
2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)
  • Het onderwerp ‘Updaten van attachment description’ is gesloten voor nieuwe reacties.