我认为您需要的是过滤器:wp_handle_upload_prefilter.
从法典中:
单个参数,
$file, 表示的单个元素
$_FILES  大堆这个
wp_handle_upload_prefilter 在文件移动到最终位置之前,您可以检查或更改文件名。
Codex中的示例代码:
add_filter(\'wp_handle_upload_prefilter\', \'custom_upload_filter\' );
function custom_upload_filter( $file ){
    $file[\'name\'] = \'wordpress-is-awesome-\' . $file[\'name\'];
    return $file;
}
 如何使用此挂钩
add_filter( \'wp_handle_upload_prefilter\', \'custom_upload_filter\' );
function custom_upload_filter( $file ) {
    if ( ! isset( $_REQUEST[\'post_id\'] ) ) {
        return $file;
    }
    $id           = intval( $_REQUEST[\'post_id\'] );
    $parent_post  = get_post( $id );
    $post_name    = sanitize_title( $parent_post->post_title );
    $file[\'name\'] = $post_name . \'-\' . $file[\'name\'];
    return $file;
}