Edits to core files break on upgrade because the update replaces the files you changed, and line numbers move. Put changes in the places your CMS provides: a child theme or sub-theme, template overrides, and hooks or plugins. Keep them in version control and test updates on a staging copy first.
From the original phpWordPress forum · archived copy
phpWordPress staff (Product Line Manager) ·
Here is a little hack to display subcategories in main category view. If you have a lot of subcategories, you probably won't display them in main navigation to keep the nav clear, so this can come very useful. 1. category_Main.tpl Place the {SHOW_SUBCATEGORIES} tag somewhere inside the template, where you want subcategories shown. Preferebly at the top of the file, above or below the {CATEGORY_NAME} tag. Format the output at will. Code:
a forum member ·
Is this instructions current? I can't find the appropriate lines or places in index.php. Quote:
phpWordPress staff (Moderator) ·
This refers to version 3.1, we need to update these hacks for release 3.2... Probably all the things are more or less the same, only line numbers in scripts differ.
a forum member ·
Thank you Would appreciate it if you can let me know once done because I tried over and over again but am unable to accomplanish this.
a forum member ·
Any further developments in this regard please?
phpWordPress staff (Moderator) ·
This is the 3.2 version of this mod: 1. category_Main.tpl Place the {SHOW_SUBCATEGORIES} tag somewhere inside the template, where you want the subcategories to show. Preferably at the top of the file, somewhere around the {CATEGORY_NAME} tag. Example: HTML Code:
a forum member ·
Is there an example of this working to view online?
phpWordPress staff (Product Line Manager) ·
We don't have one. Suppose someone who applied this mod can show live example?
View the archived thread on the Wayback Machine. Usernames and contact details have been removed.
A 2006 phpWordPress thread gave readers a hack to show subcategories on a category page: add a template tag, then edit index.php at a numbered location. A reader on a newer version could not find the lines, and staff had to republish the instructions for 3.2. The nested category display is incidental. The failure is general, and it is why customisations deserve a plan.
Why do template hacks break on upgrade?
A hack that edits shipped files has three weaknesses.
- The update overwrites it. If the installer replaces the core files, your edit disappears silently, or conflicts with the new version.
- The target moves. Line numbers, function names and surrounding code change between releases, so instructions for one version fail on the next.
- Nobody remembers it. An undocumented edit is knowledge held by whoever made it. When they leave, the next upgrade is a mystery.
Drupal’s documentation states the consequence directly: never edit base templates in core/modules, because those changes would be lost during updates.
Where should customisations go instead?
Each mainstream CMS provides places for your code that updates leave alone. The names differ, the idea is the same.
| Need | Safe place | Documentation says |
|---|---|---|
| Change how a page looks | Child theme or sub-theme | WordPress: customise without modifying the parent’s files, so it can be updated without losing your changes. Drupal: do not touch the parent theme except to update it |
| Change one template | Template override in your theme | Drupal: place a modified copy in your theme’s templates directory with the naming convention; the most specific template wins |
| Change behaviour or data | Hooks, filters or a plugin or module | WordPress: hooks let code interact with other code at pre-defined spots without altering core |
| Add a feature | A plugin or module with its own folder | Keeps code separate from core and removable |
WordPress filters illustrate the pattern: a filter takes a variable, modifies it and returns it, so your code adjusts what core produces without editing core. The result is that when WordPress or Drupal ships a new release, your layer is untouched and only needs retesting.
What would the 2006 request look like today?
The customer wanted subcategory links on a main category page. In a current system, work down this list and stop at the first one that works:
- Configuration. WordPress documents that clicking a parent category displays all posts in it and its sub-categories. Some systems have a setting for a subsection list, or a listing component you place on the section page.
- A theme override. Add the subcategory list to the category template in your child theme or sub-theme.
- A small plugin or module. If several themes need it, put the logic in a plugin using the CMS’s hooks.
- Edits to core files. Avoid them, for the reasons above.
Our answer on section pages covers how to structure the hierarchy itself.
What are the common mistakes?
- Copying the whole theme to change one file. An override should contain only the files you changed, so the rest keeps receiving the parent’s fixes.
- Pasting snippets into a theme’s functions file with no comments. Months later nobody knows which lines are yours. Put them in a named plugin or a clearly marked file.
- Editing in the live admin editor. Changes made there bypass version control and staging, and one syntax error can take the site down.
- Following a tutorial for a different version. The 2006 thread shows why: the same hack needed rewriting for the next release. Check the version a guide was written for before applying it.
- Skipping the changelog. The release notes list renamed templates and removed functions, which is exactly what breaks overrides.
How do I keep customisations maintainable?
- Keep them in version control. Child theme, plugin folders and configuration belong in a repository, so each change has an author, a date and a reason.
- Write a short README. List each customisation, why it exists, and which core behaviour it depends on.
- Prefer fewer, smaller changes. Each override is something you retest at every upgrade.
- Pin and record versions. Note the CMS, theme and plugin versions you tested against, as discussed in our answer on security patches.
- Remove what you no longer use. Dead overrides still need compatibility checks.
How do I test an upgrade?
- Take a full backup. WordPress documentation advises backing up the database regularly and always before an upgrade.
- Restore the backup to a staging environment and upgrade there.
- Open each template you have overridden, plus the pages that use custom plugins: home page, section page, article, search and archive.
- Compare against production, fix, and only then upgrade the live site in a quiet period.
- Keep the backup until you are confident nothing is broken.
If an override stops working, the diff between the new parent template and your copy usually shows what changed. This is another argument for overriding only the templates you must.
What if the CMS gives no safe extension point?
Then the vendor is telling you something about the cost of ownership. Ask their support whether the feature is planned, whether a paid add-on exists, and what the supported upgrade path is for customised installs. If the answers are poor, count the maintenance burden in your cost comparison, and put extension support on your feature checklist for the next review.
Questions people ask
Why did the old instructions stop working after an upgrade?
They told readers to edit specific lines in core scripts. A new release rewrites those files, so line numbers move and the code around them changes. Even a small refactor makes the instructions wrong, and an update can overwrite the edit completely.
What is the safest way to customise a CMS?
Use the extension points the CMS documents: child themes or sub-themes, template overrides, and hooks or plugins. WordPress hooks let code change behaviour at pre-defined points without altering core, and Drupal documents overriding templates inside your own theme.
Do I need a developer to show subcategories on a category page?
Often not. Some systems, WordPress among them, already show a parent category's sub-category posts on its page. Others have a setting or a view or listing component. A developer is needed only if you want a custom layout the editor cannot produce.
How do I test an upgrade without risking the live site?
Copy the site and its database to a staging environment, apply the upgrade there, and click through the templates you customised. Take a backup of the live database and files before you upgrade the real site, so you can roll back.
Sources
- WordPress documentation defines hooks as a way for one piece of code to interact with or modify another at specific, pre-defined spots, letting plugins and themes extend WordPress without altering core code, in two types: actions and filters. — source, checked 10 October 2026.
- WordPress filters give you the ability to change data during the execution of WordPress core, plugins and themes, taking a variable, modifying it and returning it. — source, checked 10 October 2026.
- A WordPress child theme lets you customise without modifying the parent theme's files, so the parent can be updated without losing your modifications. — source, checked 10 October 2026.
- In Drupal you override a template by placing a modified copy in your theme's templates directory using the naming convention; Drupal uses the most specific template it finds and the cache must be rebuilt for a new template to be discovered. — source, checked 10 October 2026.
- Drupal documentation says never to edit base templates in core/modules directly, as those changes would be lost during updates. — source, checked 10 October 2026.
- Drupal documentation says sub-theming means not touching the parent theme except to update it, so the main theme can be updated without re-implementing changes. — source, checked 10 October 2026.
- WordPress documentation says that clicking a parent category such as Animals displays all posts in Animals and all its sub-categories. — source, checked 10 October 2026.
- WordPress documentation advises backing up the database regularly and always before an upgrade. — source, checked 10 October 2026.