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 simple pop up form code written in javascript. It is in js/script.js folder inside themes folder.

I am using jquery ajax method to communicate with a php file to store data in db.

The php file is in themes folder. Also i would like to use the wordpress functions in that php file.

The display of pop up and form works fine. But when i submit it, i get 404 error. I am confused as to how to tell wordpress to include this php file.


EDIT: I could make the jquery code work by giving the full URL to the php file. However, now i want to be able to use the wp functins in that php file.

share|improve this question
Using WP functions from your own PHP file is a different question - so ask it separately. Also, do a search here, there have been plenty of questions about how to include WP functions in separate PHP files. – anu Mar 23 '11 at 13:15

If you want to able to use the WordPress functions the your ajax call should be to the wp-admin/admin-ajax.php and you should use wp_ajax hook,

take a look at What's the preferred method of writing AJAX-enabled plugins? I posted a nice example of how to do that there.

share|improve this answer

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.