WordPress Multisite: How to define a common upload folder for all blogs or subsites

In WordPress multisite, media uploaded from the subsite users are stored to different subdirectories using blog id into uploads folder. But, if you need to save all media files in one folder rather than uploads folder with lots of child folders, then you are in right place.

Use the following code into your theme functions.php file if you think your theme won’t be changed. Otherwise, mu-plugins is the best option.

0) {
$upload[‘path’] = ABSPATH . ‘wp-content/images’;
$upload[‘url’] = site_url() . ‘/’ . ‘wp-content/images’;
$upload[‘subdir’] = “”;
$upload[‘basedir’] = $upload[‘path’];
$upload[‘baseurl’] = $upload[‘url’];
return $upload;

function make_filename_hash($filename) {
global $user_ID;
return $user_ID . time() . $filename; /*Using time() function for uniqueness*/
add_filter(‘sanitize_file_name’, ‘make_filename_hash’, 10);

You may also read:  How to copy a list using list template in sharepoint?


You may also like...

Leave a Reply

%d bloggers like this: