Rule #1 – This is my blog.

Create New Theme File in WP-Admin without FTP

If you are working on a live WordPress site, there might come a time when you would need to upload a new theme file. This is common if you are creating new templates for a WordPress Theme.

No FTP Access

But how would you upload it if you do not have access to the site’s FTP. This is common if you are a freelance WordPress go-to-guy and your client doesn’t want to give you access to an FTP account or maybe they just simply don’t know how to set up an FTP account for you.

You may be tempted to just upload a whole new zip file containing all of the theme files. But this is a tacky way to handle it especially if the WordPress Theme contains more than 200 files and is more than 5mb. But you only need to upload one file right?

WP-Admin Solution

Go to your WordPress theme editor. http://yoursite.com/wp-admin/theme-editor.php

Edit the header.php file and add the following code at the very top or the first line.

<?php touch('wp-content/themes/practice-theme/new-file.php'); ?>

Make sure to add it outside any <?php tags otherwise it could cause an error since the code is already wrapped in its own PHP tags.

Save the changes made to the header.php file. Open a new tab in your browser then visit the website. The new file will be created.

You can now remove the code from the header.php.

The code above will create a file named new-file.php in the directory of the Theme which is practice-theme. You should change these two names to suit your needs. For example you can change the directory name to twentyten if that is the theme you are working on, or change the file name to style-extra.css if that is what’s needed.

After the New File is created you can go back to the theme editor and find the newly created file. You can now paste the file’s contents. Don’t forget to save.

WordPress Create New File

The code can be used to create any text-based file like html, php, css.

Example.

  • PHP – new-template.php, new-function.php
  • CSS – new-style.css, page-style.css

If you’re uncomfortable with editing theme files, you can always use a plugin to create a new file without needing an ftp access. This one particular plugin mimics an ftp file manager: WordPress WP-Filemanager though it doesn’t seem to work last time I checked.

Share This Post :

4 Comments

Add a Comment
  1. That is a rather illogical way of doing things. I Don’t understand why WP is so popular if any good CMS lets you do such a basic function via a click of a mouse. WP is horrifically illogical for in terms of development usability because of things like this. Use Hero Framework instead of WordPress. At least Hero allows you to do this at the click of a button.

    1. I agree, WP should have a better way of handling files on its own. Though right now there are plugins that do that. But an issue like this won’t immediately turn me away from WP. There’s a reason why many people like it and why so many have successfully made a living out of it. A huge community of user and developers have been built around it so if there’s an issue one might have he can easily seek help.

      Anyway thanks for recommending Hero Framework. I’ve never heard of it so I’m gonna give i a try.

Leave a Reply

Please write your comments in english. I delete anything that even remotely resembles spam.

Note: When posting code, enclose it in pre and code tags.
e.g. <pre><code> Add code here </code></pre>

ronangelo © 2014 Frontier Theme
css.php