Title: plugin problem &#8211; &#8220;Call to undefined function&#8221; error
Last modified: August 19, 2016

---

# plugin problem – “Call to undefined function” error

 *  [grough](https://wordpress.org/support/users/grough/)
 * (@grough)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/plugin-problem-call-to-undefined-function-error/)
 * 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)

 *  [Andrew Ozz](https://wordpress.org/support/users/azaozz/)
 * (@azaozz)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/plugin-problem-call-to-undefined-function-error/#post-669693)
 * 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.

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [undefined function](https://wordpress.org/support/topic-tag/undefined-function/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [Andrew Ozz](https://wordpress.org/support/users/azaozz/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/plugin-problem-call-to-undefined-function-error/#post-669693)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
