I've tried all I could found here and googling. Include paths, external libraries, interpreter settings...
Whenever I try to run my theme's index.php
file:
C:\XAMPP\php\php.exe "C:\path\to\project\wp-content\themes\MYTHEME\index.php"
Fatal error: Call to undefined function get_header() in C:\path\to\project\wp-content\themes\MYTHEME\index.php on line 1
Process finished with exit code 255
So yes on line 1 I'm just calling my header.
Turns out it's trying to run index.php
like a standalone file, but ignoring the whole Wordpress instalation (that I have included from different angles). Certainly it nows where get_header()
is because I can control click it and it'll bring me to the file it's declared in, no problems.
It correctly detects XAMP's PHP interpreter too.
It also works well if I just visit the site typing my localhost URL in the browser. It just won't work through Phpstorm.
You are directly calling theme's index file which is not correct way, as your theme must be using some default functions of WordPress, like
get_header()
in this case.So you need to make sure
wp-load.php
is loaded to make all WP functions available to use. You have two way for that:1) Call root
index.php
so everything will be loaded by default.2) Call theme's
index.php
but add Below code in that:However this is not good way :)