Finding hardcoded text in WordPress with String Locator
Some stubborn bit of text isn't in any setting, page or widget - it's hardcoded in a theme or plugin file. Here's how to track it down in seconds with String Locator.
Youâve checked the page, the widget, the customiser, the theme options - and that one line of text still wonât change. That usually means itâs hardcoded directly into a theme or plugin file, often by a previous developer who left no documentation. Hunting through dozens of PHP files by hand is miserable. String Locator turns it into a 30-second search.
What String Locator does
It searches every file across your themes, plugins and WordPress core for any string - text, a shortcode, a snippet of code, a URL - and shows you exactly which file and line it lives on. Itâs a free plugin from the WordPress repository, and itâs the first thing we reach for when working on an unfamiliar site full of undocumented surprises.
How to use it
- Install and activate String Locator from Plugins â Add New.
- Go to Tools â String Locator in your dashboard.
- Choose where to search - the active theme, all themes, all plugins, a specific plugin, or WordPress core. Narrowing the scope makes the search faster.
- Enter the string youâre looking for and run it.
- Read the results - String Locator lists every matching file with the line number and a preview of the surrounding code, so you can jump straight to it.
A serious word of caution
String Locator offers an in-browser editor so you can change the file right from the search results. Itâs convenient and itâs also a great way to take a live site down. Editing PHP directly means one stray character can trigger a fatal error on the whole site.
Before you edit anything:
- Back up the site first - files and database.
- Never edit a parent theme directly. Your changes vanish on the next update. Use a child theme or a code snippet instead.
- Prefer the right fix over the fast one. Hardcoded text often belongs in a translation file, a customiser setting, or a proper template override - not patched in place.
- If youâre not certain, donât. A fatal error from a misplaced semicolon isnât worth it.
String Locator is brilliant for finding things. Use something safer - SFTP, a staging site, version control - for actually changing them.
Stuck with a site nobody documented, where things change in places they shouldnât? Finding and untangling that kind of mess is one of our specialities.