How to Create a folder in wordpress if it doesn’t already exist
(Last Updated On: July 10, 2014)
Sometimes working with WordPress, you find out that your (wp-content/uploads) folder or any folder is missing. So, you might feel that you should create a code in theme that checks for the folder and if not found creates it.
Following is a sample code for creating a folder in wordpress if it doesn’t already exist. Use the code according to your situation.
if (!file_exists('path/to/directory')) { mkdir('path/to/directory', 0777, true); }