plugin problem - "Call to undefined function" error (2 posts)

  1. grough
    Posted 7 years ago #


    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.

  2. Andrew Ozz
    WordPress Dev
    Posted 7 years ago #

    That's because WP is not running. Add at the top
    to start it before calling any functions.

Topic Closed

This topic has been closed to new replies.

About this Topic