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