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.

I'm developing a plugin and I'm trying to get the url's from a post's attachments with ajax.

If the user is on a single.php page. After some seconds, I'm sending an Ajax request, getting all the attachments-url from that single post. The script is a php file located in my plugin folder.

I found out that normal functions like get_children and get_posts are not working in this script. My php log shows: Call to undefined function get_children() in /Users/tss/WWW/plugin_devel/wp-content/plugins/bggallery/ajax_nextimage.php on line 7

So I'm unable to get attachments from the post the user is viewing.

Any suggestions

share|improve this question

1 Answer 1

Read this response on how to properly use AJAX in plugins. If you just call a PHP script directly, WordPress is not loaded so no WP functions are available.

share|improve this answer

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.