How to Create a folder in wordpress if it doesn’t already exist

x theme

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);
}

Related posts:

About the author

admin

Leave a Reply

Your email address will not be published. Required fields are marked *