I am reading the documentation of WordPress Media Library and it seems to me that it doesn't allow me to split my uploaded media into directories. Is it true? Why this choice?

How can I implement that?

  • There's some plugins that I've used that do a decent job of doing so but it's not a simple or even very reliable thing to try to implement yourself.
    – Joel M
    Jan 21 '20 at 3:44

From your question what i understood is u need to store media files to another custom location. if that is your doubt then this may help you..

In order to change the default media upload location, you need to edit the wp-config.php file. If you want upload directory to be wp-content/example then you will need to place the following code in wp-config.php

define( 'UPLOADS', 'wp-content/'.'example' );

If you want the upload directory to be outside wp-content, like http://www.example.com/example/ then give it like this

define( 'UPLOADS', ''.'files' );

or you can try media file manager plugin to manage the media folders from the admin dashboard itself.


Function to create a sub-directory inside the upload directory for every upload is :

function kv_custom_image_dir( $pathdata ) {
$subdir = '/uploads_img'.$pathdata['subdir'];
$pathdata['path'] = str_replace($pathdata['subdir'], $subdir,    $pathdata['path']);
$pathdata['url'] = str_replace($pathdata['subdir'], $subdir, $pathdata['url']);
$pathdata['subdir'] = str_replace($pathdata['subdir'], $subdir, $pathdata['subdir']);
return $pathdata;
 }add_filter( 'upload_dir', 'kv_custom_image_dir' );

if you want to read more check this blog

  • now...I need have the possibility to create subdirectory into my standard media directory, for example: "logos", "brochures", "articlesImmages",etcetc Jul 17 '14 at 12:01
  • ok..so u need to create folders inside wp-content/uploads similar to the default month folder right??
    – Zammuuz
    Jul 17 '14 at 12:12

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.