Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

../wp-content/themes/my-theme/php/ajax-handler.php

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

include('../../../../wp-blog-header.php');

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);

require('../../../../wp-blog-header.php');

Warnings gone, but $wpdb not recognized.

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

share|improve this question

1 Answer 1

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

 
discard

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.