LittleBizzy

Dominate technical SEO with a SlickStack cloud server for just $39/month!  Order Now

Create A New WordPress Theme File Without FTP

Sometimes when you are designing a custom WordPress template you will need to create a new theme file. For example, you may already have common files such as index.php or single.php but you may require a new file, e.g. page-contact.php in order to design a custom contact page. Luckily, there is a VERY EASY way to do this even without FTP access!

1. Firstly, ensure that you have administrator access to your WordPress backend. This method will only work if you have admin access and are able to edit files under the APPEARANCE >> EDITOR context menu.

https://www.example.com/wp-admin/theme-editor.php

2. Next, determine the name of the theme directory your WordPress site is using. For example, if you are using the Avada theme, your theme directory would be wp-content/themes/Avada/ or so forth. If you are not sure, simply visit your homepage and select “view source” in your browser (CONTROL + U in Chrome/Firefox) and try to find some HTML code that confirms what your theme directory currently is (i.e. search “wp-content/themes” using CONTROL + F).

3. Finally, using PHP’s touch function, we will create a new theme file. Copy and paste the below code snippet into the very top (seriously, the very top) of your theme’s header.php file, and then click save.

Note: this file creation method is not limited to PHP files, and can be used to generate any file type.

<?php touch('wp-content/themes/YOUR_THEME/FILE_NAME.php');?>

4. After you click save, open your homepage in a new tab, and your new file should be created immediately. You can verify this by revisiting the file list under APPEARANCE >> EDITOR and checking to see that your new theme file exists.

5. Finish up by removing the code snippet from your header.php file, and then click save again. Keep in mind that as long as the code snippet is live, that file will keep being re-generated whenever someone visits your website. So make sure that you don’t begin editing your new file (adding code, etc) until you have properly removed the PHP touch snippet from your site.

CONGRATS! You are done. Just another good reason not to rely on FTP for so many things :)

About the Author

Jesse

Leave a Reply

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