0

I'm working in developing REST API for a WP based website. Endpoint is http://example.com/api.php I've included wp-load.php in the top of the file to access WP functions etc.

However, http://example.com/api.php is loading normally in browser (not output as no parameter is passing). When I'm passing any parameters like http://example.com/api.php?items=books I'm WordPress getting non found error page.

Most wired part is, when I've disabling Pretty Permalink, everything is working normal.

3
  • 1
    Please edit your question and use code formatting for example links and use http://example.com, which is the default domain for examples. Thanks.
    – kaiser
    Commented Sep 30, 2014 at 8:13
  • @kaiser, do you have any idea what is going on in my system?
    – IFightCode
    Commented Sep 30, 2014 at 10:52
  • 2
    "I've included wp-load.php in the top of the file (...)" is what causing you the main issues. You are practically bypassing WP. Just search and read on other questions that include wp-load.php to find answers on how to do it right.
    – kaiser
    Commented Sep 30, 2014 at 23:29

1 Answer 1

1

I can't say I've ever tried including wp-load.php directly, but I've had success using:

define("WP_USE_THEMES", false);
include("wp-blog-header.php");

... when trying to invoke Wordpress stack in a non-templated workflow. wp_blog_header.php does make the call out to wp-load.php but also wires up some other stuff (such as calling wp()).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.