Initial assessment without passwords Quote before intervention One accountable specialist from start to finish

Errors & Diagnosis

WordPress “Cannot Redeclare Function” Fatal Error: How to Fix It

This fatal error means the same function name was defined twice. It is usually a duplicated snippet or two plugins clashing. Here is how to trace it.

Short answer: “Cannot redeclare function …” is a fatal PHP error meaning the same function name was defined twice. PHP refuses to run, so the site (and often the admin) goes down. The log points straight at both locations.

Read the two locations

Enable WP_DEBUG_LOG and open /wp-content/debug.log. The error names the function and the file/line where the second declaration happened, and usually references the first. Those two paths are your answer — you just need to remove or rename one of them.

The common causes

  • A code snippet pasted twice — into functions.php and also into a snippets plugin.
  • Copying a function from a tutorial that already exists in your theme.
  • Two plugins shipping a helper with the same generic name (for example a common utility function without a prefix).
  • A child theme redeclaring a function from the parent without a function_exists() guard.

Fix it over SFTP

  1. Open the file named on the second declaration line and remove the duplicate, or wrap it in if (! function_exists('name')) { ... }.
  2. If two plugins clash, deactivate one by renaming its folder in /wp-content/plugins and decide whether you need both.
  3. If a snippet was pasted twice, delete the duplicate copy.

Verify

Reload the site and the admin, and confirm the feature that used that function still works. If the clash was between two plugins, check whether the one you kept covers what the other provided, so you are not left with a missing feature after removing the conflict.

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.

WP RepairDiagnostic model
1Request2PHP / server3WordPress4Component
Follow the chain until you find the first point that stops behaving as expected.
01

Record the function name and both file/line locations.

02

Determine whether the code is duplicated, bundled by two plugins or loaded twice by an include.

03

Remove the unintended copy or namespace/prefix the custom code.

04

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.

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.

BEFORE YOU SEND THE REQUEST

Frequently asked questions.

Do you ask for passwords in the form?+

No. The public form never requests access. Secure credentials are requested only after the scope and quote are approved.

Who reviews the incident?+

The request goes to Jordi Ensenyat, founder of Code Barcelona and a WordPress specialist with more than 15 years of experience.

Is anything changed before the quote?+

No. Visible symptoms and scope are reviewed first. Intervention begins after approval and with a rollback path prepared.

Do you work internationally?+

Yes. WP Repair handles WordPress and WooCommerce incidents in English and Spanish through a remote service.

Assess my incident