0

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?

4

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

|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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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