Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting

How to Fix PHP Errors in WordPress: Causes and Fixes

How to Fix PHP Errors in WordPress: Causes and Fixes

Short answer

Turn on WP_DEBUG_LOG to record the exact error, then read the file path it names. Deactivate or update the plugin or theme in that path, undo recent code edits, update code for your PHP version, and raise the memory limit if the error mentions memory.

Key takeaways

  • The error's file path usually names the plugin or theme at fault.
  • Log errors to debug.log instead of showing them to visitors.
  • Rename a plugin folder to disable it without dashboard access.
  • Parse errors come from recent code edits with typos.
  • Update plugins before blaming a PHP version upgrade.

How do you fix PHP errors in WordPress?

Turn on debug logging to read the exact error, find the file path it names, then update, replace or disable the plugin, theme or custom code responsible.

Almost every PHP error message tells you three things: the type of error, the file and the line number. The file path is the most useful part. If it contains wp-content/plugins/some-plugin, that plugin is your suspect. If it contains wp-content/themes, look at the theme.

The steps below go from quick checks to deeper fixes. Take a full backup before you edit any file, even if the site is already broken.

What causes PHP errors in WordPress?

Most PHP errors come from plugin or theme bugs, code that is not compatible with your PHP version, typos in custom snippets, missing files after a failed update, or hitting server limits like memory.

Common triggers include:

  • A plugin or theme update that introduced a bug or needs a newer PHP version.
  • A PHP version upgrade on your host that broke older code.
  • A snippet pasted into functions.php with a missing bracket or semicolon.
  • An interrupted update that left half the files in place.
  • Running out of memory on a heavy page or import.

Knowing what changed just before the error appeared often points straight to the cause. Think back to the last update, new plugin or code edit.

Some fatal errors show no message at all. The browser just reports an HTTP 500 Internal Server Error, which is a generic server failure that very often hides a PHP problem underneath.

What do the different PHP error types mean?

PHP errors range from harmless notices to fatal errors that stop the page, and the type tells you how urgent the problem is.

Error typeWhat it meansBreaks the site?
NoticeMinor issue, like an undefined variableNo
DeprecatedCode uses a feature that future PHP will removeNo, but warns of future breakage
WarningSomething failed, but PHP kept goingUsually no
Parse errorSyntax mistake, such as a missing bracketYes
Fatal errorPHP could not continue, such as an undefined functionYes

The official PHP error constants list defines each level in detail.

Notices and deprecated messages on screen look alarming but rarely need urgent action. Hide them from visitors, log them, and report them to the plugin author. Fatal and parse errors need fixing right away.

How do you see the full PHP error message?

Enable WordPress debug logging in wp-config so errors are written to a log file instead of being hidden or shown to visitors.

Open wp-config.php through your host's file manager or FTP. Above the line that says to stop editing, set these constants:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Reload the broken page, then open wp-content/debug.log. The newest lines at the bottom show the error with its file and line number.

The WordPress debugging documentation explains every constant. Our guide on how to read the WordPress debug log shows how to interpret the entries.

Turn debugging off again when you finish. A public debug.log file can leak server paths.

Can WordPress recovery mode help?

Yes, when a fatal error hits, WordPress often emails the admin a recovery mode link that lets you log in and disable the plugin or theme causing the crash.

Check the admin email inbox, including spam, for a message about a technical issue on your site. The link opens a special session where the broken extension is paused for you only.

From there, go to Plugins and deactivate or update the named plugin. Our guide to using WordPress recovery mode covers what to do if the email never arrives.

If you see the message There has been a critical error on this website, that is WordPress catching a fatal PHP error. Our walkthrough for fixing the critical error message goes deeper.

How do you fix an error caused by a plugin?

Deactivate the plugin named in the error path, then update it, roll it back to an older version, or replace it with an alternative.

If you can reach the dashboard, go to Plugins and deactivate it there. If you cannot, connect by FTP or file manager and rename the plugin's folder inside wp-content/plugins, for example by adding -off to the end. WordPress then skips it.

Once the site loads again:

  1. Check whether an update is available and install it.
  2. If the error started after an update, roll back with a tool like WP Rollback.
  3. Check the plugin's support forum for the same error.
  4. Report the error, with the log line, to the developer.

If the error path does not name a plugin, deactivate all plugins and reactivate them one at a time. The Health Check and Troubleshooting plugin can do this for your session only, so visitors are not affected.

How do you fix an error caused by your theme?

Switch to a default theme such as Twenty Twenty-Five to confirm the theme is at fault, then update it or undo the last change to its files.

You can switch themes under Appearance, then Themes. Without dashboard access, rename the active theme's folder in wp-content/themes. WordPress falls back to an installed default theme.

Theme errors very often come from code added to functions.php. Undo the last snippet you added. A safer place for snippets is a code snippets plugin or a child theme, so updates do not wipe your changes and mistakes are easier to undo.

How do you fix a parse or syntax error?

Open the file and line named in the error, look for a missing semicolon, bracket, quote or stray character, and correct it or remove the snippet you just added.

Parse errors almost always appear right after someone edits a file. The line number in the message is where PHP noticed the problem, which may be a line or two after the real mistake.

Common culprits are curly quotes pasted from a web page, a missing closing brace, or an opening PHP tag added in the middle of a file that already has one.

Our step-by-step guide to fixing a parse error syntax error shows examples of each.

How do you fix errors after a PHP version upgrade?

Update every plugin and theme first, then replace anything that is still not compatible, and only roll back the PHP version temporarily while you fix it.

Hosts regularly move sites to newer PHP releases as older ones lose support. You can see which versions still get security fixes on the PHP supported versions page.

Older code may call functions that newer PHP removed, which causes fatal errors such as Call to undefined function. Our guide on fixing a site broken after a PHP update walks through the safe order of steps.

Going back to an old PHP version is a short-term patch, not a fix. Old versions stop getting security updates.

How do you fix memory and timeout errors?

Raise the PHP memory limit or execution time in wp-config, php.ini or your host's panel, and look for the plugin or process using too much.

A message like Allowed memory size exhausted means a script hit the memory ceiling. You can raise WordPress's limit with the WP_MEMORY_LIMIT constant, but the host's own limit still caps it.

Our guide to fixing allowed memory size exhausted covers each method. If raising the limit only delays the error, a plugin is probably stuck in a loop or loading far too much data.

Which fix matches which error message?

Match the wording of your error to its most likely cause, then go straight to the right fix.

Error message containsLikely causeFirst fix
syntax error, unexpectedTypo in edited fileUndo the last code change
Call to undefined functionMissing plugin or old code on new PHPUpdate or replace the code
Allowed memory size exhaustedMemory limit too low or heavy pluginRaise memory limit
Cannot redeclareSame function loaded twiceRemove the duplicate snippet
headers already sentExtra space or output before headersRemove whitespace in the named file
failed to open streamMissing file after bad updateReinstall the plugin or WordPress core

For the headers message, see our dedicated guide to fixing headers already sent.

How do you stop PHP errors from coming back?

Keep WordPress, plugins, themes and PHP up to date, test updates on a staging site first, and keep a recent backup you know how to restore.

A few habits prevent most PHP errors:

  • Update plugins regularly rather than all at once after months.
  • Remove plugins you no longer use.
  • Add custom code through a snippets plugin, not by editing theme files live.
  • Watch the debug log on staging after big updates.
  • Use Query Monitor to spot PHP notices and slow code while logged in.

When an error persists after all of this, contact your host with the exact log line. Hosts can see server error logs that WordPress cannot, and our guide on checking PHP error logs shows where to find them.

Frequently asked questions

Where do I find PHP errors in WordPress?

Enable WP_DEBUG and WP_DEBUG_LOG in wp-config, reload the broken page, then open the debug log file inside the wp-content folder. Your host's control panel also keeps server error logs, which can catch errors that happen before WordPress fully loads.

Should I hide PHP warnings on my live site?

Yes. Visitors should never see PHP notices or warnings, because they look broken and can reveal server paths. Set WP_DEBUG_DISPLAY to false and log errors to a file instead, then fix the underlying issue or report it to the plugin author.

Can a PHP error damage my database?

Usually not. Most PHP errors stop code from running rather than changing data. An error in the middle of an update or import can leave data half saved, though, which is why a recent backup matters before you start fixing things.

Why did PHP errors appear when I did not change anything?

Something may have changed without you: an automatic plugin update, a host moving your site to a newer PHP version, or an expired license disabling part of a premium plugin. Check the debug log date and your host's notices to find the trigger.

Do I need a developer to fix PHP errors?

Not always. Many errors are solved by updating, deactivating or rolling back a plugin or theme. If the error sits in custom code you do not understand, or keeps returning after updates, a developer or your host's support can save time.

Sources

  1. Debugging in WordPress WordPress Developer Resources
  2. Predefined error constants PHP Manual
  3. Supported versions PHP
  4. Health Check and Troubleshooting WordPress.org
  5. Query Monitor WordPress.org

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.