1

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.