So far I can see my media file is divided into month and year as 2008/09 like directory. But I am getting concerned because I am currently hosting a community listing site that may incurr more than 1000 upload (which is the limit for most shared hosting for EACH directory). I realize recently that the shared site can not have more than 500,000 file/ file in combine. So I think it will be getting pretty limited after a while.

Anyone has solution for this issue in term of changing the archieve frequency maybe into every week instead of every month? I googled it but can never find a answer for it all at! Or...am I getting into a wrong direction?

Please help thank you all!


Assuming you want to set your weekly changing subdirs like, eg '2013/W35' /where 35 stands for 35th week of 2013 ('W' param of php date() function),

you can use:

add_filter('upload_dir', 'set_folder_to_week', 999);

function set_folder_to_week ( $upload_data ) {
  $y = date('Y');
  $w = 'W' . date('W');
  $subdir = "/$y/$w";
  $dir = $upload_data['basedir'] . $subdir;
  $url = $upload_data['baseurl'] . $subdir;
  return wp_parse_args(array('path'=>$dir, 'url'=>$url, 'subdir'=>$subdir), $upload_data);

All media uploaded before still continue to be founded and displayed correctly by wordpress (if they are retrieved using the proper wp functions).

Note that I've added 'W' before week number in subdir name to avoid, on the first 12 weeks, url and path are the same of the standard /year/month path.

  • Thanks! Its seem really proceedable! I will try it out later! Appreciated :D ++ – Adam Aug 31 '13 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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