WordPress call to undefined function get_header();

2019-02-20 04:23发布

问题:

Firstly, I have looked for previous posts about this topic, but none have the answer that I need. So I shall rephrase to fit my problem best.

I'm taking my first crack at creating a very basic WordPress theme. I've got all the template files that I want, and while checking my files for errors, I see that I'm getting an error for every file.

Fatal error: Call to undefined function get_header() in blah/blah/blah.....etc

I've seen many posts where people simply say "FTP a clean install" or "You moron, you changed the index.php file in the root directory!" The answer is no, this function is called in and only in my theme directory.

Any help would be HUGELY appreciated!

Thank you.

回答1:

Generally this happens when someone has mistakenly put index.php from a theme in the WP install folder, where it overwrites the index.php that is the main WordPress file.

That is, the index.php that lives in the root directory (thats the directory with the wp-config.php in it) is NOT an editable theme file.



回答2:

get_header()
is not a PHP function and thats why it is throwing Fatal error: Call to undefined function

get_header()
is a wordpress function - have you loaded the wordpress function prior to running this function - this is usually done with an include?