Skip to content

Instantly share code, notes, and snippets.

@rajeshstarlite
Created May 1, 2017 07:23
Show Gist options
  • Save rajeshstarlite/c8aa50903a19725103185629cb14b86c to your computer and use it in GitHub Desktop.
Save rajeshstarlite/c8aa50903a19725103185629cb14b86c to your computer and use it in GitHub Desktop.
WordPress: Create new sub directory in the uploads directory

WordPress: Create new sub directory in the uploads directory

Some times it's required to create folder inside the /uploads/ directory of WordPress. WP Codex function wp_mkdir_p() comes to rescue you. Let's say you want to create a folder StarLite inside the /uploads/ directory then below is code:

$your_folder_name = 'StarLite';
$upload_dir = wp_upload_dir(); 
$your_folder = $upload_dir['basedir'] . '/' . $your_folder_name;
if(!file_exists($your_folder)) wp_mkdir_p($your_folder);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment