I have a custom PHP script (which is importing Wordpress via wp-load.php) that I've used successfully on many sites in the past, yet it's misbehaving on one particular site seemingly after a couple of Wordpress updates (currently version 4.7.1).

The situation is this:

  • The PHP script, requiring wp-load.php, is called via javascript to process form data.
  • The form processing worked just fine until a few weeks ago. Now it's throwing a 500 internal server error.
  • The PHP logs are showing errors like this:

    PHP Fatal error: Cannot redeclare my_wp_nav_menu_args() (previously declared in /path/to/site/wp-content/themes/uc/functions.php:15) in /path/to/site/wp-content/themes/uc/functions.php on line 18

  • The error seems to indicate that functions.php is being called twice. To test that, I commented out all functions in functions.php and, voila, my PHP script worked just fine.

  • Despite this, the rest of the site works just fine...although it does load pretty darn slowly, and I'm running it on my local machine. Hmmm.

  • FYI, there's really nothing special or out-of-the-ordinary about the rest of the site. I use ACF for a lot of stuff but have never had issues with that.

Could it be true that functions.php is somehow being called twice? If so, how? Has anyone else had a similar issue with any recent WP core updates? Will Mary Beth and Victor ever find true love?

Find out all of this and more on the next episode of "Burning Money the Wordpress Way"!

Any help would be SOOO appreciated.

  • 1
    The mentioned error doesn't say that functions.php was included twice, it only says that my_wp_nav_menu_args() function was declared previously in functions.php on line 15 and then again in functions.php on line 18. Please double check the error and functions.php. Possibly there are two functions.php (one in parent theme and the other in child theme), or perhaps there are two my_wp_nav_menu_args() function declaration in the same functions.php file.
    – Fayaz
    Jan 17, 2017 at 7:16
  • For clarity, there are no nested themes and only one functions.php. And I'm certain there are no redundant functions in that script. The particular function mentioned in the example just happens to be the first function declared in the script at that time. I actually organized different functions at the top of the script and noticed that it would fail at whatever function was first. And the line numbers indicated are always 1-3 lines apart. It seems to me that the most compelling information in that error is "previously declared in". Why would it be previously declared at all? Jan 17, 2017 at 7:47

2 Answers 2


Ah, jeez: the ol' check-all-your-plugins-first routine would've saved me some time.

Apparently a 3rd-party ACF plugin, https://wordpress.org/plugins/acf-google-font-selector-field/, was the cause of the issue. The slow page loading I mentioned was also remedied.

That's too bad. I need that stupid plugin.


1) I think the problem should be solved, if in your custom php script, you will do exit; after execution of your desired actions.

2) Also, you can use something like this in the start of your functions.php:

if (in_array(__FILE__, get_included_files())) return;

Your Answer

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

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