How to Edit Your WordPress Theme Files

The theme editor, with file and theme selector

If you’re interested in tweaking your WordPress site to suit your needs, chances are that at some time or another you will need to edit some of the theme files, if you want to get exactly what you want.

Fortunately, WordPress makes this very easy by providing an in-browser editor that you can access from within your WordPress admin area. Without that, you would need to use FTP and edit the files directly.

The Editor is found under the Appearance menu

The Editor is found under the Appearance menu

Getting to the editor

Once you have logged in to your admin area, select the Appearance menu from the sidebar on the left-hand side of the screen. From there, you will see the Editor menu (this should not be confused with the Plugin Editor, which can be found under the Plugins menu and enables you to edit a different set of files).

Editing the files

You’ll now be presented with a screen like the one to the right. From the right, you will see all the theme files for your currently active theme. (You can edit files of other themes by selecting the theme from the drop-down in the top right hand corner.)

The theme editor, with file and theme selector

The theme editor, with file and theme selector

On the right is a listing of all the files – the most common of these are header.php, single.php, page.php, footer.php and index.php. It depends on what you are trying to achieve as to which file you will want to edit. The tutorial should explain which file to edit.

Limitations and notes

Note that in order to edit files from within the editor, the files themselves will need to have permissions of at least 666. The built-in editor also has some limitations, which other editors don’t have. For example, there is no search/replace function, no line numbers, and no highlighting.

Remember, you should ALWAYS back up your files before you edit them in case you make a mistake. As soon as you save the file, it goes live and the old file is irretrievable.

11 thoughts on “How to Edit Your WordPress Theme Files”

  1. I always get a backup of my entire theme + database before I touch editing my files.. You write some great content and keep rocking..

    1. Dave says:

      Thanks Srivathsan. Yes, no doubt about it – backups should always be made before making any changes. I’ve learnt the hard way a few times before!

  2. Kimi says:

    I agree backup files is a must.

    Editing wordpress themes are not too hard even if we know a little bit of coding.

    But editing Thesis theme is different, we have to know how hooks works, etc.

    Thanks for this useful post Dave, it sure helps other beginners!

    1. Dave says:

      Ahh yes, I haven’t yet had the chance to work with Thesis. If I ever get to the point of needing/wanting to create my own theme, that’s definitely where I’ll be starting.

      P.S. I had thought the Prowl error was just with me – I’ve deactivated that plugin. Thanks for the feedback!

      1. Kimi says:

        Anytime Dave!

        Glad you got it fixed :)

  3. Kimi says:

    AWwwwwww..whenever i submit comment in your blog this things appears:

    Fatal error: Cannot redeclare class Prowl in /nas/wp/www/cluster-2010/doitwith/wp-content/plugins/wp-prowl/ProwlPHP.php on line 4

    Have you tried to comment yourself to see if it happens? or is it just me? lawll..

  4. Ashok Kumar says:

    i want to add a slideshow in my wordpress theme…..i found difficulty in including javascripts and css file….how can i properly add these files…please suggest

    1. Adding CSS and JS should be done using the wp_enqueue_script and wp_enqueue_style functions.

  5. Ashly says:

    i want to edit header.php from theme editor , but on clicking the update button it is redirecting to 404 page . but updating the other pages does not make any problem
    Please help me to solve this

    1. Hmmm, not sure. Maybe the page is timing out when you try to update. I’ve experienced getting 404s on admin pages before when trying to perform an arduous task.

  6. Ashly says:

    its not timingout.Every time having the same issue

Leave a Reply