How to upload all media to one folder, with no year/month subfolders

user2187609 asked

Prior to version 3.5 (or thereabouts), WP had a checkbox to select if all uploaded media went into sub-folders of /uploads, named by month and year. If checkbox was unchecked, all media ended up in one folder - no subfolders.

How can I restore that feature? I.e., I want all my media to go into one folder and NOT be further divided into year and month. Is there some easy programmatic way to achieve that? Or is there some reliable plugin to do the job?



Pop this tiny code snippet into a file located here:
wp-content/mu-plugins/upload-dir.php (a must use plugin file).
Create the mu-plugins directory if it does not exist already.

add_filter( 'pre_option_uploads_use_yearmonth_folders', '__return_zero');

What you’re doing here is filtering an option value at runtime, which is picked up internally by _wp_upload_dir() and therefore uploads are no longer nested into date-based subdirectories.

Share This
Posted in: