我的Web服务器上有1000多张图片,通过FTP上传到本地文件夹(/home/chris/pictures
)
有没有办法将它们作为众所周知的媒体添加到PHP中的wordpress中并获取它们的id?
while ( $the_query->have_posts() ) : $the_query->the_post();
$post_id = get_the_ID();
$filemakerID = get_post_meta($post_id, \'filemaker_id\', true);
$file[\'url\']=\'/home/chris/picture_export/\'.$filemakerID.\'.jpeg\';
$file[\'type\'] = \'image/jpeg\';
//THE DREAMED FUNCTION WOULD BE USED THIS WAY
$photo_id = awesome_function( $file, $post_id);
add_post_meta($post_id, \'photo\', $photo_id );
}
正如您所注意到的,我的照片用于自定义字段photo
也在google dans codex上呆了几个小时后,我注意到这些函数的文档记录非常糟糕。也许我就是想不出正确的关键字来搜索。