My Site gives a few errors about notices and depreciations that I would like to fix. For example:

Got error 'PHP message: PHP Deprecated: add_option was called with an argument that is deprecated since version 2.3.0 with no alternative available. in /home/public_html/wp-includes/functions.php on line 5067

The line of code it referes to is not the cause of the error, it is the Wordpress debug code intercepting the error. How do I find out the actual line causing the error?

2 Answers 2


The reason why the error message refers to a line in a WordPress core file instead of a theme or plugin is because it's within the function itself that the error occurs, not in the place where add_option() is called.

If you want to be able to trace through the code to discover the originating file, you can use an extension like xdebug, which will allow you to generate a stack trace, like this one:

example xdebug stack trace

From this we can see that the offending plugin is called example.php, and the function that calls add_option incorrectly is called some_buggy_function().

As far as fixing the error itself, previous versions of WordPress used a third argument to add_option which is now deprecated. Removing that argument or setting it to an empty string '' will remove the warning.

  • It's probably not great to add xdebug to production server. I could download the site and run it locally to debug. Hopefully wordpress will fix it at some point.
    – Will
    Oct 21, 2020 at 14:28
  • @Will it doesn't need to be permanent, you could install and just switch on long enough to receive the stack trace, and then turn off. Agreed that error debugging should happen in a local server. This isn't something WordPress can fix; it's likely an issue with your theme or plugins
    – shea
    Oct 21, 2020 at 14:30
  • This kind of stuff comes up loads with WP, because there is all sorts of code thanks to plugins & themes. "install xdebug on production" can't be the right answer.
    – Will
    Oct 22, 2020 at 15:45
  • What else is WordPress core supposed to do? The correct answer is to not use plugins or themes containing outdated code, especially on production.
    – shea
    Oct 23, 2020 at 7:18
  • Theme and plugin issues are inevitable - wordpress should show the error with enough detail to debug it.
    – Will
    Nov 3, 2020 at 16:54

You could simply run a RegEx search in your editor for add_option\(.+,.+,.+\); and check the results manually. Shouldn't be too much. Alternatively you can run or running $ grep -r 'add_option\(.+,.+,.+\);' . from your command line

  • I dont think that will work. What we really need to know is what the argument was that was invalid. In a dynamic theme like a pagerbuilder for example, that could be calling add_option many times, with many different arguments. It's normal for a system to give the actual error. Wordpress is intercepting the error and giving less detail than if it didn't.
    – Will
    Oct 14, 2020 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.