3

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?

Thanks!

3 Answers 3

2

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.

<?php
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.

0
3

Can you not just un-tick the box in Admin -> Settings -> Media:

Wordpress media settings

3
  • No because this checkbox was removed after version 3.5 (or 3.4 or 3.6 - can't recall), so the easy obvious fix is no longer available. Nov 4, 2017 at 20:27
  • I'm on 4.8.3, but with a custom install. I'll have a check and see how I (accidentally?) enabled this option again. Nov 4, 2017 at 20:32
  • 1
    I just did a fresh install of 4.8.3 and the option in the screenshot I posted is there. Nov 4, 2017 at 21:48
1

This is an screenshot from WordPress 6.1.1:

WordPress admin media settings

I can confirm that even with version 6.1.1, Alexander's solution works perfectly.

So there must be some issue on the OP's own settings. WordPress still has this Settings in the admin panel to enable or disable month- and year-based folders.

2
  • I know, Fayaz. I have been on other SE groups for over 12 years now, but new in this one. As I wrote, I cannot comment other answers yet, that's why I did that. I just want to draw attention to this post, because the accepted solution is unnecessarily complicated, compared to Alexander's answer. I wouldn't mind deleting my answer, once I have enough reputation to comment and vote.
    – Flo
    Feb 9, 2023 at 23:37
  • OK, I've edited your answer. Now it can be considered as an answer itself. Cheers.
    – Fayaz
    Feb 10, 2023 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.