I have a custom post type that i want to access through jQuery - preferably using JSON.
So first things first. creating a function that returns/echos json is easy enough, but how would I access it through jquery.
as Mike writes in this question, he - as far as I understand - places it in the wordpress root. which would make it accessable using the php file name - but Is this recommendable? I would rather put it inside a plugin folder.
I have tried reading the wordpress codex, but the way ajax calls are handled just confuses me, as you are posting every ajax call to admin-ajax.php, even though it is not an admin page?
Can someone please straighten out the problems I'm having?
The problem I had was understanding how ajax calls were to be made in wordpress, as well as where to place your php and js code to do/handle the calls.
In the other question I linked to, you created a function placing the file in the wp root - I dont want to do that. But I have now learned how to use the wp_ajax_(nopriv_)[action] and can effectivly access the json i create. The problem remaining is Where i should place the JS to make the call. I want to place it in the plugins js file, but as this is to be presented in a page, not on the admin site, ajaxurl isn't defined, so i have to echo using php.