How to Add PHP Files in WordPress Theme without FTP

Did you ever want to create new WordPress theme template PHP files, but needed FTP access to the 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 shortcodes.php in your theme directory called qotstrap.

<?php touch('wp-content/themes/qotstrap/shortcodes.php'); ?>

Here is what it will look like in the theme editor

create php file

Save the header.php file and you will find a blank php file created called nav.php.

new php file

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.

Get template parts in WordPress

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. If you want to load a theme file like share_buttons.php in single.php which displays the posts, simply use the get_template_part code like this in single.php

<?php get_template_part(' share_buttons '); ?>

I am sure WordPress theme designers will find this tip handy.


  1. karim morgo says:

    what id i want to continue creating the theme without using FTP access !?

  2. Olamosh says:

    wow! Bravo P Chandra,

    Am a wordpress wrangler but i never knew of this method. To sincere you make my day with this article post.

    This is really a great way to create a new PHP file/template inside a wordpress theme.

    I have always create my php file/template offline and connect through FTP in order to upload it. I never knew of this method.

    Thanks for sharing this wonderful trick with us, it shows our geeky you are towards wordpress development and i will urge you to keep up the good writing.

    BUT PLEASE, AFTER CREATING THE FILE, WILL YOU HAVE TO REMOVE THE “” from header.php ???? (await your response)

    I already bookmark this blog because i see alot of interesting articles on it.

    Have a nice weekend

    • P. Chandra says:

      Once you have created your file, you do not need the line in the header.php. It has to be removed.

  3. Hardy says:

    Thanks for the tips. It is very useful for the newbies like me..

  4. Bluecsi Discount says:

    Just Awesome Tips. But When i am Trying to Upload 50 MB WordPress Theme, Then how i can Upload it without FTP ?

    • P. Chandra says:

      This works to create empty files in the themes folder. Fresh install need to be done by FTP or in one click via Softalicious or Fantastico in your cpanel.

  5. Bradley Elliot says:

    is this really help in exporting the hosting & username detailed?

  6. Cynthia Kincaid says:

    I have created isolated php file PHPTest.php and accessed using path similar to above mentioned one. Its working perfectly. However my query still open i.e. when the same code is pasted in template related php file it is not even showing the controls.

  7. Jennifer Smith says:

    Well, this thing does really helps when you are testing different themes. I will try it for sure on my new wordpress blog as I have still not decided which theme to use. Thank You for sharing.

  8. mayur says:

    themes are really important as far as appearance is concerned. i am new to wordpress i am trying out for a theme which is simple in appearance and loads faster

  9. rocky kumar says:

    Thank you for posting your blog. I had not any idea about this but you given smart idea for me. I will definitely follow your tips.

  10. david says:

    I find it diffult to understand, i think i need to read it again

  11. Alok Negi says:

    You can easily create or delete any wordpress file if you have cPanel access.

Leave a Reply

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