A lot of us use a WordPress website to promote our business, our blog, to share content and images with our friends and family. Regardless of whether you are a new WordPress website user or an old, experienced one, at some point in time, you’d want to incorporate a few minor or major code changes to your website. The change could range from anything like improving basic functionality of a website that doesn’t have a fully working plugin or creating a family based theme. It could be absolutely anything, and such changes require careful planning.

This is where the crucial dos and don’ts of code editing your WordPress site come into play. Also, there are some areas you might do well to stay clear of. We’ll learn how to do just that in the following lines.

WordPress Posts vs. Pages

Once you are logged into WordPress dashboard, you’re ready for a website update.

Click the Pages button. Go to All Pages. You’ll see the first 20 pages of your website. If you have more than 20 pages, use the search pages box located in the right corner to find the pages.

To edit a page, move your mouse to the space given below the name of a page. You’ll see a menu for edit, quick edit, trash etc. The edit option will let you add or delete photos, content etc. Quick edit will let you update page name and things like that.

What Are WordPress Core Files?

WordPress core files are open to all for viewing, editing and accessing. But just because you can edit them doesn’t mean you should. WordPress core files are required for the optimal functioning of WordPress. They make the platform a convenient one to manage and create content for viewing in internet browsers. While we can safely get rid of readme.html and license.txt without altering WordPress, the files called index.php, xmlrpc.php and the ones prefixed with wp are the core ones.

The files included in the directories wp-admin and wp-includes are core files that you shouldn’t touch. Wp-content has plugins, caches, uploads and images: things that aren’t core.

Never Hack The WordPress Core!

Sometimes you or your clients desperately need a particular feature on your WordPress website. You do a bit of a research on the internet and find that you’d need to edit core files for the purpose. Now this is a problem.

If you’ve spent at least some time with WordPress experts, you must have come across this golden piece of advice: Do not hack WordPress core. It means that you should absolutely stay away from core files that are the basic files that are important for WordPress’s functioning.

Why not? While there are plenty of reasons for you to do so, we’ll state some of the important ones:

  • A plugin exists for the purpose: When you hack WordPress core, you are basically doing the job of a plugin: adding to, changing or bending the way WordPress functions. Plugins are a far easier and more acceptable way of going about the job than hacking core.
  • Your website isn’t insured against future issues: If you ever happen to edit the core of WP, it is impossible to update the site or maintain previous changes, which means that if an update happens and you try to initiate the process, the upgrade will overwrite your customization settings. Any editing done to a core file is wiped off of the very face of the web. Core file edits are temporary, in place only till an upgrade comes along. If you wish to have your customizations intact, you will have to read those whenever there is an upgrade to be done. As is obvious, it is a waste of time.

Now you know why you shouldn’t hack WP core. Let’s look into the aspects you can safely change.

What Really Happens When You Hack The Core

Give this a thought. Assume you have hacked the core. Since you are so pumped up, you make critical edits in the complicated, intricate core files. Now you refresh your website (the copy). Your website looks great and works just as well. You take a deep breath and pat yourself on the back.

A few weeks later, you get a notification saying your core needs to be updated. What do you do now? You can’t skip these crucial updates, since now your website is old and vulnerable to threats. However, if you upgrade, you’ll lose your edits by copying new core files over the old ones.

You have quite a few options at your disposal now. You can refuse to upgrade. Your website will slowly deteriorate and eventually wear out. The next option is to upgrade instantly, forgetting about the edits you made weeks ago. You don’t notice anything amiss unless your visitors start asking you why major features from your website are missing. The next option is to do the edits all over again on the new files. You have the edits stored from a few weeks ago. The problem here is that some of the upgraded files will be vastly different. Finding the right places to edit could prove to be a task. If an update comes out a few weeks later, you’re going to have to repeat the process all over again.

All the above options are painful to carry out. When you hack the core, you don’t win. But this doesn’t mean people never hack the core. They do, but usually as a last resort. A good developer should figure out how to do the task by overriding core files instead.

Now that you know why you shouldn’t hack the core, let’s look into the aspects you can safely change.

Overriding Core

A well designed CMS website is going to let you override the core. You don’t lay a finger on the core files but make changes in separate files. When your core code will run, it will have in-built program to check for the custom files. On finding them, it will run your changes.

Hence, your changes will override the core default behaviour. You can do a smooth, clean upgrade by separating your changes from core files. Since your changes are saved in separate files, it doesn’t matter what changes are brought by new core files upon upgrading.

The File Structure Of WordPress

A screenshot of a regular WordPress installation file structure will look like this:

As you can see, there are a variety of files with 3 top stage folders.

The folders that are off limits are wp-include wp-admin and. You shouldn’t be touching them. The folder labeled wp-content stores your plugins, themes and documents uploaded in the past. Use functions.php file to customize your theme.

When it comes to top-level files, you’ll only need to access wp-config.php. We’ll discuss examples of editing both these files later. For now, we’ll look at some of the best tactics used to edit WordPress files.

How to Edit WordPress Files using Best Practices

WordPress’ core functionality will primarily have a plugin and theme editor, which you will see in the installation process when you select the Appearance and then Editor tabs from the sidebar.

After you’ve seen it, remember that you must never make use of WordPress editor, be it for any purpose whatsoever. That is it. Here’s why this feature must be entirely removed from WordPress:

  • The WP editor isn’t a completely operational code editor hence you can easily commit errors that will lead you to the dreadful ‘’white screen of death’’.
  • You can’t undo it after you’ve saved changes. No second chances. Most high quality code editors let you undo changes if they don’t really function as you thought they would.

So, is there an alternative? If you must need a code editor’s help, the first thing you need to do is familiarize yourself with FTP.

FTP means File Transfer Protocol, which is just a roundabout way of putting the fact that one is transferring files and documents from one’s system to the server that hosts your website. You will have to connect your website via a reliable FTP client, then download your file that you will modify, make the required changes followed by uploading the edited file onto the server, which will overwrite the old file.

A lot of good, popular code editors give you the option of editing files on your server. A few of them will let you pre view your changes. If you have a code editor that performs this function, it’s a great move to save one duplicate of the old file giving it a different name (something on the lines of filename_old.php). This gives you the freedom of deleting this newly created file, changing the file name back to the old one, if you ever commit a slip-up you cannot undo it.

Edit WP files now

It’s time to get started with the real business. We will now perform sample editing operations on two files – functions.php and config.php. These two aren’t theme based files and will be frequently edited by you.

How to Edit wp-config.php File

This is among the primary and most crucial files part of one’s WP installation. The wp-config.php file doesn’t have WordPress’s default installation. You need to download a file called wp-config-sample.php. While you are at the program for installation (primarily entering database information), you will have to create wp-config.php or you could rename wp-config-sample to wp-config, entering the database information manually. Both these files can be found in your web directory’s root. If you entered your database information in the installation program, you have created the wp-config.php already.

The wp-config.php file is never overwritten in the event of an update. In WordPress, the default bunch of core files doesn’t include wp-config.php. It is only created during the installation of WordPress. The template for this file is wp-config-sample.php. WordPress uses the sample file to make wp-config.php. This contains important information like database username, database name, database password and other important settings used for WordPress installation.

Since this file is not going to be overwritten in the event of a WordPress update, we can safely edit wp-config.php with a valid code. Let us perform a few edits.

How to Edit Functions.php File

Using the functions.php file, you can modify and bend the default, in-built behavior and setting of WordPress. This file performs the job of a plugin and allows the user to make additions to the functionality and features of their WordPress website. You will find this file in the theme folder that is found at wp-content/themes/yourthemename. In case there isn’t one available, you can create it in quick, easy steps. However, ensure that you are placing this file in the targeted theme.

If you happen to be starting this operation using a newly made file, you will have to open its php script. You do not have to shut the script, unlike a traditional PHP file.

Write Your Own Plugin/Module

Essentially, you want to build or write your own plugin or module. Plugins and modules are simply the special changes that your core files will look for before running. Even if you happen to be making tiny little changes, it might do you good to figure out how to do the task with plugins and modules, rather than attacking core WordPress files.

If your core changes a little too much, it won’t keep track of your customizations any more. However, a well designed CMS stays consistent. When you upgrade to the next major WordPress version, you will need to revise your plugin. Since a new major version means major changes in core, it also means changes in plugins. However, revising plugins with the next version is far simple than altering core files with every small upgrade.

Moral of the story: Don’t fiddle with the core. Work on plugins. You’ll look back with contentment. Now that you are well aware of what you need in order to edit core files in WordPress and how to go about it. It’s about time to apply your knowledge to an actual editing operation. All the best!