WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I added a new file in the theme folder and it doesn't seem to be working properly.

The first line get_header(); creates an error Fatal error: Call to undefined function get_header() like it's not seeing any includes.

Any ideas why that happens? All files in the same theme folder work just fine except this one.

share|improve this question
What Theme are you using? What file did you add to the Theme? How/in what context will WordPress use/render this new file? – Chip Bennett Mar 6 '12 at 16:01
I am using a custom theme and I added a file called "sendEmail.php" which takes data from an AJAX call and sends an email using wp_mail(). – user13874 Mar 6 '12 at 16:18
I think the issue is that you're trying to use WordPress functions outside the context of WordPress. Just a suggestion, but you might get more effective answers if you re-phrased your question as how to take data from an AJAX call and send an email using wp_mail(). – Chip Bennett Mar 6 '12 at 16:38
up vote -1 down vote accepted

You are prbebaly using wordpress elements outside the loop and since its a file ou dont access directly from wordpress structure but a file you created yourself you should include


Above the doc type opening tag in sendEMail.php file..

share|improve this answer
Don’t include wp-load, please. My wp-content directory may be on a different directory outside of the WordPress directory. Good luck finding wp-load.php! :) – toscho Mar 7 '12 at 7:19
i see... does that "moving files around" really happens? i havent noticed that wp-load.php moved since 2.1 (which is the first verstion i installed) - not ideal solution for sure but real easy for a single, few files which you just want to put into your design no? – Sagive SEO Mar 7 '12 at 8:14
Yes, it happens. I have fixed performance problems for some clients, and part of the job was it to move the wp-content to another, cookieless domain. Themes or plugin searching for wp-load.php would just die then. – toscho Mar 7 '12 at 8:20
i see.. ok ;) thanks – Sagive SEO Mar 7 '12 at 8:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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