Debugging WordPress with Xdebug - PHP Fatal Error: Uncaught Error: Call to undefined function get_header()

submited by
Style Pass
2021-05-29 04:28:47

And set a breakpoint on line 2, and run 'Debug functions.php', then I hit that breakpoint and I'm able to debug that breakpoint in PhpStorm. So far so good!

PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /path/to/project/wp-content/themes/my-theme-name/functions.php:44 #0 {main} Stack trace: thrown in /path/to/project/wp-content/themes/my-theme-name/functions.php on line 44

Like page.php. Same thing - if I add my demo-code (and breakpoint) in the top, then it works. But if I move it to the bottom, then it stumbles over get_header(). The error:

PHP Fatal error: Uncaught Error: Call to undefined function get_header() in /path/to/project/wp-content/themes/my-theme-name/page.php:6 Stack trace: #0 {main} thrown in /Users/zethodderskov/Code/Greenmind/V2-1__local/app/public/wp-content/themes/my-theme-name/page.php on line 6

And if I set a breakpoint in an imported class, then it doesn't stop at that breakpoint (even though I'm 100% sure that it reaches that part of the code).

Leave a Comment