Did you ever want to create new WordPress theme template PHP files, but needed FTP access to server every time. We experiment a lot with WordPress theme designs and it was very cumbersome to keep logging in via FTP to create new theme files like loop.php Â or nav.php or other php files to make the code easier to edit and understand.
There had to be an easier way…
New WordPress TemplateÂ Files Without FTP
PHP has an amazing command called ‘touch’ which allows users with rights to create new php files. So when you are logged in, simply go to Appearance > Editor > header.php and add this single line of code.
Lets say you want to create a new file called nav.php in your theme directory called quickpress.
<?phpÂ touch('wp-content/themes/quickpress/nav.php'); ?>
Here is what it will look like in the theme editor
Save the header.php file and you will find a blank php file created called nav.php.
Now you can addÂ whatever code you like to that.
Note: It is very essential that now you remove the line added to the header.php and save the file again.
Super tip – We prefer breaking down long WordPress template codes into smaller PHP files which are easier to edit and call in the template, such that they can do instant changes throughout the site. It is easy to call these theme template files anywhere in the theme template like this
<?php get_template_part('Â navÂ '); ?>
I am sure WordPress theme designers will find this tip handy.