when you work with files over FTP clients, sometimes you will need a quick access to them without having to log in to your FTP service. For example, you might be working from a computer which doesn’t have an FTP client installed and it would be much faster just to create a new file directly from WordPress.
To prove you different, we will now show you how to create a new WordPress file without having to use FTP.
step 1. Log into WordPress and navigate to ‘Appearance > Editor’.
step 2. On the right-hand side you will see a list of files in the current theme.
step 3. Open header.php file from your theme’s folder
step 4. Add the following code as the first line of the file.
notes: touch() is a PHP function used to sets access and modification times on files. If the file doesn’t exist however it does create it which is what we want.
step 5. Replace YOUR_THEME_DIR with the name of your theme directory in which your WordPress theme lives.
Then, replace FILE_NAME with the name of the file you want to create.
step 6. Save changes.
Now you can find your newly created file on the right side menu. As you imagined, the file is completely empty and waiting for your code.
step 7. Navigate back to ‘Appearance > Editor’ in the WordPress backend and remove the code you added in step 4 to prevent it from being executed again.
You should also notice that the new file you created above is present in the right-hand side list of files ready for you to edit to your content.