Wordpress未创建图像缩略图

Wordpress未创建图像缩略图,wordpress,Wordpress,我在前端有一个自定义上传功能,用于自定义帖子类型。如果我在后端编辑文章,则特征图像显示为附件,但在媒体库中,它只是一个默认占位符。我的图像代码有问题吗?就好像它没有“生成wordpress缩略图” $uploaddir = wp_upload_dir(); $file = $placeholder; $uploadfile_pl = $uploaddir['path'] . '/' . basename( $file['name'] ); move_uploaded_file( $file['

我在前端有一个自定义上传功能,用于自定义帖子类型。如果我在后端编辑文章,则特征图像显示为附件,但在媒体库中,它只是一个默认占位符。我的图像代码有问题吗?就好像它没有“生成wordpress缩略图”

$uploaddir = wp_upload_dir();
$file = $placeholder;
$uploadfile_pl = $uploaddir['path'] . '/' . basename( $file['name'] );

move_uploaded_file( $file['tmp_name'] , $uploadfile_pl );
$filename = basename( $uploadfile_pl );

$wp_filetype = wp_check_filetype(basename($filename), null );

$attachment = array(
    'post_mime_type' => $wp_filetype['type'],
    'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
    'post_content' => '',
    'post_status' => 'inherit',
    'menu_order' => 1000
);
$attach_id = wp_insert_attachment( $attachment, $uploadfile_pl, $post_id);
require_once( ABSPATH . 'wp-admin/includes/image.php' );

$values = wp_generate_attachment_metadata($attach_id, $uploadfile_pl);
wp_update_attachment_metadata($post_id, $values);

set_post_thumbnail( $post_id, $attach_id ); 
我明白了

wp_update_attachment_metadata($post_id, $values);
应该是

wp_update_attachment_metadata($attach_id, $values);

愚蠢的打字错误

还是没什么好运气。有人能提供见解吗?