Hacking WordPress: wp-includes/general-template.php

Opening up the Codex file (wp-includes/general-template.php) and editing it is not recommended. The most basic reason is that any work you do on this file will be written over on the next update. As of version 4.1, updates happen automagically. Unless you write a plugin, your changes won’t stick.

You can still edit things to play around, knowing full well that your changes won’t stick. The other thing to remember though, is you might make a wreck of things, and that isn’t good. I recommend messing around in a developer environment or with a blog that won’t ruin your business if it goes down.

Never one to follow my own advice, I went straight in and hot edited this file to insert a phrase at the start of page titles. Do find the file in the first place, I opened the theme’s folder (in my case, a child of WordPress’s Twentyfifteen) and found the method wp_head(). I had to then turn to the Codex to locate the source.

Once I knew where the source file was, I opened it and went looking for the method and voila! Adding a phrase to page titles is a matter of inserting it in the method statement dealing with title, a sub routine called wp_title(). This is the information needed to write plugins, which I’ll cover as I go if I get ambitious enough.