• I’ve written a short script to be called by Prototype’s Ajax object and return a list of posts using the get_posts() function. My script lives in the wp-includes directory.

    When I make the AJAX call to the script, I get the response “Fatal error: Call to undefined function get_posts()”, so I assume I must include wp-include/post.php (where the function is defined) in my script. But when I do this I get another error, saying that I can’t redefine functions defined in wp-includes/post.php, so the file must already have been included as I assumed initially.

    I’m confused by this… can anybody suggest a solution? Thanks

Viewing 1 replies (of 1 total)
  • wow, 8 months. People are not being very helpful. Thought I’d post this as this page shows up often in Google.

    you need the following line on top of your .php file:

    <?php require_once(“./wp-blog-header.php”); ?>

    If it is sitting outside the wordpress installation directory just change the url to reflect that.

Viewing 1 replies (of 1 total)
  • The topic ‘Trouble with AJAX & get_posts()’ is closed to new replies.