Rename UPLOADS folder with custom WP_CONTENT_DIR

After digging around, I ended up with using upload_dir filter.

Here is what I tried in functions.php to change uploads to media. Hope it can help someone too 🙂

 add_filter('upload_dir', function($uploads)
 {
     $custom = [];

     foreach ($uploads as $key => $value) {
         if ( false !== strpos($value, '/app/uploads') ) {
             $custom[$key] = str_replace('/app/uploads', '/app/media', $value);
         } else {
             $custom[$key] = $value;
         }
     }

     return $custom;
 });

Many thanks to @gmazzap for the guidelines and the suggestion about upload_dir filter!

Leave a Comment