“Cannot redeclare function” means PHP has encountered another declaration of a function name that is already defined. The error can stop the request and leave WordPress showing a critical-error screen. Start with the full error and the two code locations, rather than adding a guard to every function.
If the failure began after a release, our WordPress plugin update recovery service reviews the error, affected feature and recovery options. A site becoming visible again is only one part of the repair.
What to capture before changing code
Keep the error text, date and time, affected URL or action, and versions changed just before the fault. A message such as Cannot redeclare example_helper() may identify the second declaration and a previously declared file and line. This is an illustrative function name, not a command to run on your site.
A file named in an error is a lead, not proof that the entire plugin is defective. Check both declarations and how they were loaded. If only one location appears, inspect the loading path and the earliest related fatal error.
Where to look for the duplicate
- The same snippet in a theme and a snippets plugin.
- A helper function supplied independently by two components.
- A file included twice during one request.
- A child theme declaring the same function as its parent.
- A function declaration inside a routine that is called more than once.
Use the guide to isolating a WordPress plugin conflict if the fault depends on a combination of components. Avoid interpreting “the site loads when this plugin is off” as a complete explanation.
Read logs without displaying errors to visitors
Ask the hosting provider for the relevant PHP error log if it already exists. For WordPress debugging, follow the official logging guidance; logging and displaying errors are separate settings, and a log can contain information that should remain private. Do not paste a full unreviewed log into a public request.
On a staging copy, reproduce the failing route and record which declaration is encountered first. If staging is unavailable, agree a limited intervention and recovery route before changing a component used by checkout, forms or account access.
Choose the correction that matches the cause
Duplicate custom snippet: keep one maintained copy and remove the second from the identified location after preserving it. Check registrations and callers so the required behaviour remains.
The same file loaded twice: review the loading code. PHP’s require_once construct skips a file already included. It does not resolve two different files that each declare the same helper.
Two distinct components: compare supported versions and ask the component author for a fix. In custom code, a suitable prefix or namespace may separate ownership; renaming a function also requires updating its callers. Do not rename a function inside third-party code without considering updates and dependencies.
Why function_exists is not a universal repair
A conditional function_exists() check can be appropriate when a function is deliberately designed to be supplied by another component. It can also silence a collision while the wrong implementation remains active. Compare the function’s inputs, outputs and callers before adopting that approach.
The PHP function reference explains declaration rules. A repaired request must still produce the result that the application expects; avoiding a fatal error is not enough.
Verify the original feature and the next update
Test the original failing URL or action, admin access and the feature that called the function. Include the relevant form, booking or checkout path, using a controlled test where it can create a transaction. Confirm that the same error does not recur in fresh logs.
Record the changed location, retained implementation, tested version and route back. If a temporary plugin deactivation was necessary, document the function that remains unavailable and how it will be restored. A rollback of files must also account for any data changes made by the update.
When to request a recovery assessment
Escalate when the site is unavailable, two paid components conflict, the error comes from maintained third-party code, or a recovery could affect current orders or submissions. Prepare the plugin or theme versions, redacted error, affected route and available backup.
Request an assessment of the update or conflict, or review how WordPress recovery is scoped and verified. The assessment determines the repair; this guide does not guarantee a specific cause or turnaround.
WP REPAIR INCIDENT STANDARD
How to narrow the fault without guessing
Cannot redeclare identifies two definitions with the same function name. The log paths show where each copy loaded, which is safer than adding a guard without understanding why duplicate code exists.
Record the function name and both file/line locations.
Determine whether the code is duplicated, bundled by two plugins or loaded twice by an include.
Remove the unintended copy or namespace/prefix the custom code.
Use function_exists only when optional override behaviour is genuinely intended.
What must be verified
- Only one intended definition loads.
- The dependent feature works with the final load order.
- Cache, opcode cache and restart do not bring the fatal back.
Official technical sources
Continue the diagnosis
This guide explains the diagnosis. If the site is affected now, the intervention should preserve a rollback path and verify the real business journey.
See the emergency repair service →ABOUT THIS SYMPTOM
Frequently asked questions about this guide.
Can I fix a "cannot redeclare function" error just by clearing my cache?+
No. This is a PHP fatal error that happens before WordPress renders anything, so caching plays no part in it. The only fix is editing the file that contains the duplicate function definition, over SFTP or a file manager.
Why does the error log only show one file, when two files actually clash?+
The log line points at the second declaration, the one PHP was processing when it hit the duplicate name, and it usually references the first occurrence in the same message. Read the full error text rather than just the file path at the start of it.
Is it safe to just delete one of the two functions?+
Only if you know which copy is actually used and confirm the other is a true duplicate, not a slightly different version. If the two definitions differ, deleting the wrong one can silently change behavior instead of just removing redundancy.
Will wrapping a function in function_exists() always solve this permanently?+
It stops the fatal error, but only if the two versions of the function are functionally interchangeable. Wrapping a plugin's helper in a guard while relying on a different theme version of the same name can mask a real incompatibility instead of resolving it.