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 have a voting system on a custom post which uses AJAX, and I have a file that handles the AJAX request. This file is inside a sub folder named php of my theme. Hence the structure is:


I use the following line to include the blog-header.php file:


This works fine, but with debug mode on, I see warnings telling me that WP failed to open the stream as the file blog-header.php is non-existent.

So I tried this:

define('WP_USE_THEMES', false);


Warnings gone, but $wpdb not recognized.

Any ideas on how to make this work without the warnings?

share|improve this question
up vote 4 down vote accepted

The "right way" is to not include it at all and use WordPress provided means for AJAX in themes and plugins.

share|improve this answer
Yes you're right about it, but I used this method when it was an emergency and I found it easier, but now that module is an integral part of a big system. Seems like I'm gonna have to use WP-AJAX after all! Thanks! – Rutwick Gangurde Dec 15 '11 at 18:43

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.