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.

So I'm working with ThemeTrust's "reveal" theme, and there is an ajaxed in chunk-of-content that I'm really trying to change (grab custom meta fields (images) + insert into a slideshow). As far as I can tell the following piece of code grabs the content from the normal tinymce box and drops it in the #projectHolder div - but I can't figure out how to piggyback my php code on this request.

function loadProject(projectSlug) { 
// Scroll to the top of the projects    
jQuery("#projectHolder").load(      
    MyAjax.ajaxurl,
    {           
        action : 'myajax-submit',           
        slug : projectSlug
    },
    function( response ) {   
    }
);
}

I suppose my answer lies somewhere in the 1500+ lines of wp-admin/admin-ajax.php but that seems awful daunting...

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The function that returns the contents of that ajax request will not be in admin-ajax.php. That is the core WordPress file that handles ajax requests, but it is not used for specifying the data returned by ajax functions in themes / plugins.

In the theme (somewhere), will be a line that looks like this:

add_action('wp_ajax_myajax-submit', 'some_function_name_here');

The function called "some_function_name_here" (which will be named something different than some_function_name_here, as this is just an example) is what determines the data returned to jQuery.

Do a search in the theme files for "add_action('wp_ajax_myajax-submit'" and you should be able to find it.

If you don't find it with that search, then look for

"add_action('wp_ajax_no_priv_myajax-submit'"

share|improve this answer
    
Awesome, Thanks! I think I had it almost figured out after tracing the code a bit and reading garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress.. but you undoubtedly just saved me a fair amount of work. –  Zach L May 31 '12 at 21:11

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.