• Resolved markowe

    (@markowe)


    OK, I have a REST endpoint at myapp/v1/mydata which, without going into detail, returns some JSON data from a plugin of my own making (to be retrieved by the front end via AJAX) and it has all worked fine for over a year.

    However, I have JUST discovered that posts are being created for each response (or maybe not EACH – some) in wp_posts. Like in this screenshot: https://i.imgur.com/G7qJvIv.png

    The post_content is the JSON data, i.e.my API response, and the post_name is derived from the name of the endpoint.

    It looks like some sort of caching, but I understood that REST API responses are not automatically cached. Without delving too much, does anyone have the remotest idea why it would be doing that? I have tens of thousands of posts I don’t need in my wp_posts table…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Joy

    (@joyously)

    I would look through the code of your plugin for where you told it to create posts.

    Thread Starter markowe

    (@markowe)

    Well, I will have to, even though I have never written any code that creates posts in any way, I wouldn’t even know how to do it without referring to the documentation. I was hoping there might be some mechanism whereby the REST API does it for some reason, but guess not…

    Thread Starter markowe

    (@markowe)

    OK, I now note that these entries have not been happening for a while. I am going to conclude that at some point I ran a caching plugin that took it upon itself to cache the REST responses as posts in wp_posts. Leaving this here for posterity and closing the topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Why does REST API create posts in wp_posts with the content of the response?!’ is closed to new replies.