How To Create a New Theme File in WordPress (WithOUT FTP Access)

July 26, 2011    27 Comments

A quick 3 step post here on how to create or add a new PHP file in your WordPress theme directory without having FTP access.

If you don’t even know what FTP access is, this post is for you :)

And it doesn’t have to be a PHP file, you can create any file with this method.

Here are a couple assumptions before moving forward:

  • You have a self-hosted WordPress website ( version)
  • You have ADMIN access to your WordPress dashboard control panel area
  • Assuming you can use the Theme Editor (Appearance -> Editor) and save the changes to files

To create a new file in your WordPress theme directory…

Step 1: Know Your Theme Directory & File Name

You will need to know the directory in which your current active theme is running (and thus, the directory to which you want to add a new file).

Hop over to Appearance->Themes … You see the current theme that’s running (it’s the bigger one relative to any that are under it).

You will have to activate a different theme than the one which your site is running on, then look for “All of this theme’s files are located in /themes/YOUR_THEME_DIR.” — Once you learn the theme’s directory, quickly reactivate the theme your site was running on :)

Also, know the name of the file you wish to create as that will make this much easier.  Know the extension too (is it a .html, .php, etc… type of file?)… I call this FILE_NAME.

Step 2: The (simple) PHP code

Using touch(); PHP function, which creates a new file in the specified directory.  This is how I suggest doing it (and admittedly, there are cleaner ways, but this will get the job done, quickly and effectively)…

Open header.php — then write this code in the very top of the file:

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

Replace YOUR_THEME_DIR with the directory in which your WordPress theme lives.

Then, replace FILE_NAME with the name of the file you want to create.

Once that’s all done, save Header.php and go to the homepage of your site.

As soon as the homepage loads, it will create that new template or theme file.

Step 3: Remove the PHP Code

Quickly go back to your theme editor and remove that line of PHP code I told you to put in there earlier.

You’re DONE!

Don’t believe me? – Go to your theme editor (Appearance -> Editor) and refresh that page.  You should see your new FILE_NAME on the right side.

I hope this how to helped you add or create a new PHP or HTML theme/template file in your WordPress theme directory.

If you had troubles, I recommend hiring a professional web developer :)

Written by: Arsham Mirshah (79 Articles)

WebMechanix co-founder, technical SEO, Google analytics junkie, & web dev'r who loves to ski, play tennis and demonstrate ROI.

Follow Arsham on Twitter    
  • Bachigun

    can you help me.. i want add file php for vote. where i must put the file in wordpress?

    • Arsham Mirshah

      Hi Bachigun, please provide more detail if you’d like me to help :)

      • Vb

        thanks for the article Arsham !!! Worked instantly

        • Arsham Mirshah

          Nice! that’s what I like to hear :)

  • Brendon Rell

    Awesome, awesome, awesome.  Thanks so much, huge help!

    • Arsham Mirshah

      Thanks, thanks, thanks! You’re very welcome Brendon! :)

      Do you need help with anything else? I like taking suggestions from real people and writing blog posts around them.



  • Bailey

    Thank you!! I’m very new to wordpress and have no idea what I’m doing so this helps a lot! I was wondering if you could help me with something… I’m using the twentyten theme right now and am trying to add “pages” to the bar underneath the header image. I’ve been playing around on wordpress for a few days but can’t figure it out!

    Right now the only “page” is Home. How do I add more?

    • Arsham Mirshah

      Hi Bailey,

      In the administrative panel of WordPress, look for “Pages” — you should find it at the top of the left sidebar.

      Click “Add New” under the “Pages” heading.. From there you can fill out the title and content, then when you publish, it should land you a link under the header image!

      Let me know if that works — if it doesn’t, we might have to look at your menu structure, settings, or source code.

      • Bailey

        I tried that and it just adds the info underneath the header and I can only have one.  Instead of giving a link it shows all of the info. Not sure if that makes sense so I’m including a picture. What I want is for pages like “About” and “Current Studies” to be next to “Home”.

        • Arsham Mirshah

          Admittedly, that’s really weird. When I’m using the TwentyTen theme, any page that I add automatically adds to the navigation bar.

          Try upgrading your theme or installing Twenty Eleven.

          Also, take a look inside of Settings -> Reading to see if a tweak in there doesn’t help.

          Honestly, I can’t help beyond this without having access to the site :( — Let us know how you fair!

  • Fatima Burke

    Great Job….solved my problem very quickly. :)

    • Arsham Mirshah

      Happy to hear it Fatima :)

  • Mpelevatorsolutions

    Hello i’ve just added a blank child theme however i’m having troubles
    figuring out how to get the text of my pages out of what appears to be
    the right sidebar especially when my layout is supposed to have the
    sidebar on the left according to my theme options? Also would you happen
    to know how to change my menu into a horizontal selection without the
    bullets and how to delete the non sense on the menu bar? All it has
    under the editor is the theme functions, which is blank and the style
    sheet. Can you please help me with the customizations? I’m completely

    • Arsham Mirshah

      Hi there, we can certainly help you.. it sounds like you need some heavy customization! Please contact us via our contact form and we’ll go from there..

  • Heather Cash


  • Matthew

    Many thanks!

    • Arsham Mirshah

      Glad it was useful :)

  • Sid

    Lot of Thanks dear .. It’s great !!!

  • Farzad

    It’s so useful! Thanks Arsham :D

  • Narender

    I have tried this.Template created and then inserted my php code in template file.It is not showing on my website

    • Arsham Mirshah

      Have you set a page to run off that template?
      Try creating a page called ‘testing.php’ and put ” in there .. Then point your browser to that file, /wp-content/themes/your-theme/testing.php

      Let us know what happens!

      • Narender

        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. Please advice.

  • Narender

    thanks for your reply.If you have any video clip regarding the same please send me.

    • Arsham Mirshah

      I would have to make the video.. sorry Narender, don’t really have time to make that happen right now!

  • Narender

    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. Please advice.

    • Arsham Mirshah

      I’m not sure what you mean here Narender.. please rephrase.

  • Sally Keter

    Thanks, worked like a charm