• Hi,

    I’m writing a plugin that includes a PHP script to be loaded/excecuted via an AJAX request. The script includes some standard WP functions; get_posts() as an example.

    The script works fine normally, when included anywhere in my theme’s code. However, when I request the script file via AJAX, the standard WordPress functions always yield the following error:

    Fatal error: Call to undefined function…

    Does anyone know why this might be? Thank you.

Viewing 1 replies (of 1 total)
  • That’s because WP is not running. Add at the top
    require('./wp-blog-header.php');
    to start it before calling any functions.

Viewing 1 replies (of 1 total)
  • The topic ‘plugin problem – “Call to undefined function” error’ is closed to new replies.