WordPress Shows Fatal Error: Cannot Redeclare Function
Two pieces of code define the same function. Usually two copies of one plugin or a theme duplicating a plugin.
Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
What it means
PHP found the same function name defined twice.
Common reasons
- Two copies of one plugin installed in different folders, such as
pluginandplugin-copy. - A theme and a plugin both include the same helper code.
- A snippet pasted into
functions.phpthat a plugin already provides.
Fix
- Read the error: it shows both files.
- Deactivate and delete the duplicate copy.
- If you added code to the theme, remove the repeated function or wrap it in a check for an existing function.
- Update the theme or plugin that is out of date.
Use a child theme for your own code. See WordPress Child Theme: Why You Need One and How to Create It.
Related guides
- YouTube Video Embed Not Working or Showing an Error on Your Website
- Yoast SEO or Rank Math Sitemap Shows 404 or Is Empty
- WordPress XML Sitemap Gives 404 or Is Not Generating
- Changed the WordPress Address (URL) and Now the Site or Login Is Broken
Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.