尝试以下操作:
add_filter(\'wp_handle_upload_prefilter\', \'limit_wp_handle_upload_prefilter\');
function yoursite_wp_handle_upload_prefilter($file) {
  // This bit is for the flash uploader
  if ($file[\'type\']==\'application/octet-stream\' && isset($file[\'tmp_name\'])) {
    $file_size = getimagesize($file[\'tmp_name\']);
    if (isset($file_size[\'error\']) && $file_size[\'error\']!=0) {
      $file[\'error\'] = "Unexpected Error: {$file_size[\'error\']}";
      return $file;
    } else {
      $file[\'type\'] = $file_size[\'mime\'];
    }
  }
  if ($post_id = (isset($_REQUEST[\'post_id\']) ? $_REQUEST[\'post_id\'] : false)) {
    if (count(get_posts("post_type=attachment&post_parent={$post_id}"))>3)
      $file[\'error\'] = "Sorry, you cannot upload more than four (4) image.";
  }
  return $file;
}
 在将其粘贴到主题函数中之后。php上传限制应为每篇文章总共4个文件。