您可以非常简单地添加一些操作来存档它。
function wpse_16722_main_uploads() {
switch_to_blog(1);
}
add_action(\'load-media-new.php\', \'wpse_16722_main_uploads\');
add_action(\'load-media-upload.php\', \'wpse_16722_main_uploads\');
add_action(\'load-media.php\', \'wpse_16722_main_uploads\');
add_action(\'load-upload.php\', \'wpse_16722_main_uploads\');
add_action(\'admin_init\', \'wpse_16722_main_uploads\');
这将在的帮助下,将当前的子博客更改为用户主站点
switch_to_blog 当然,您希望主面位于id 1旁边。
您还可以添加一个函数,将上载文件夹重写为仅上载/不上载子文件夹:
function wpse_16722_upload_dir( $args ) {
$newdir = \'/\';
$args[\'path\'] = str_replace( $args[\'subdir\'], \'\', $args[\'path\'] ); //remove default subdir
$args[\'url\'] = str_replace( $args[\'subdir\'], \'\', $args[\'url\'] );
$args[\'subdir\'] = $newdir;
$args[\'path\'] .= $newdir;
$args[\'url\'] .= $newdir;
return $args;
}
add_filter( \'upload_dir\', \'wpse_16722_upload_dir\' );