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

Originally I hacked together Agile Carousel and WordPress by passing wp-load.php into the AJAX script but clearly that isn't the way to go. I've now read that wp-admin/admin-ajax.php is better, but I can't yet trigger the add_action('wp_ajax_nopriv_...') method.

How can I find out what the action value is? Without knowing this, what other ways can I trigger a method that has access to all of WordPress' variables/functions?

share|improve this question
Can you include the part of the javascript that makes the AJAX request? – Stephen Harris May 2 '12 at 7:29
The line in Agile Carousel that fetches the data is $.getJSON("AJAX-URL", function(data) { – MechEngineer May 3 '12 at 15:42

After some digging, I decided to try a hunch and it ended up working. Whether this is the sanctioned solution or not, but it has worked in my testing.

For the AJAX url, add the $_GET variable ?action=[ajax_action] where [ajax_action] is your requested action. (ie. http://www.example.com/wp-admin/admin-ajax.php?action=[ajax_action])

Then make add_action('wp_ajax_nopriv_...') include your action variable, ie. add_action('wp_ajax_nopriv_[ajax_action]', 'ajax_callback') and to make sure it works for logged in users, include add_action('wp_ajax_[ajax_action]', 'ajax_callback') as well.

I imagine that a similar solution would work for more generalized AJAX requests.

share|improve this answer

That action value is whatever you define - just be sure to add the same action to the source URL for the Agile Carousel - something like that: "AJAX-URL?action=carousel" ... and the hook should look about like that:

add_action('wp_ajax_carousel', 'name_of_the_function_to_call_here');
add_action('wp_ajax_nopriv_carousel', 'name_of_the_function_to_call_here');
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.