$file_dir = WP_CONTENT_DIR . '/uploads/foo/';

Why would you need to use wp_mkdir_p when mkdir can do its job here?




There is not much a difference but, for wp_mkdir_p() we can only pass the full path to attempt to create a folder. It is recursive directory creation function which check for the file_exists() or not. And moreover we don't need to pass the folder permission because it checks for the parent directory permission and sets the folder permission as that of the parent directory.

But, with mkdir() we need to check for the file_exists() function before creating a directory and the directory permission will be set as the permission defined by the WordPress itself during the setup.

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.