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'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

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


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.