试试这个,可能会有帮助
已转换为CSV文件上载到根文件夹,根文件夹具有给定的列结构,其中包含附件image ID 和alter text
- run this code for one time only
$row = 1;
if( ($handle = fopen ( "Book1.csv", "r" )) !== FALSE ) {
while ( ($data = fgetcsv ( $handle, 1000, "," )) !== FALSE ) {
$image_id = $data[ 0 ];
$image_alt_text = $data[ 1 ];
update_post_meta ( (int) $image_id, \'_wp_attachment_image_alt\', $image_alt_text );
}
fclose ( $handle );
}