CMS Mastering Development Wordpress

WP REST API returns empty posts despite entries in wp_posts

Using WP API to query posts. There are many entries in wp_posts, but the API always returns an empty array.

Request: /wp-json/wp/v2/posts/

Response: []

Request: /wp-json/wp/v2/posts/3553


    "code": "rest_post_invalid_id",
    "message": "Invalid post ID.",
    "data": {
        "status": 404

Yet, querying MySQL directly:

SELECT count(*) FROM wp_posts;

returns 391

SELECT count(*) FROM `wp_posts` where id = 3553;

returns 1

Is there some inherent filtering in the API? I am stumped here.


Leave a Reply

Your email address will not be published. Required fields are marked *