admin管理员组

文章数量:1424910

When I am querying for posts of a CPT, I get a response of 200 but a return of brackets [].

How can I show all of my CPT post data?

My syntax I am using in the url is: http://mydomain/wp-json/wp/v2/myCPT

When I am querying for posts of a CPT, I get a response of 200 but a return of brackets [].

How can I show all of my CPT post data?

My syntax I am using in the url is: http://mydomain/wp-json/wp/v2/myCPT

Share Improve this question edited Jun 15, 2019 at 2:05 samjco-com asked Jun 14, 2019 at 21:47 samjco-comsamjco-com 5996 silver badges19 bronze badges 2
  • Did you set 'show_in_rest' => true, when registering the post type? – czerspalace Commented Jun 14, 2019 at 23:57
  • Yes. It is. And if I add an ID to the syntax it will show just that 1 post. But I was trying to get a list. – samjco-com Commented Jun 15, 2019 at 1:07
Add a comment  | 

1 Answer 1

Reset to default 0

So I tried everything and every plugin to fix my issue and expose the list CPT data instead of showing brackets [ ].

And the answer is something that might be a bug in Wordpress Rest API.

The problem was I am using custom statuses and none of my posts were assigned as default Wordpress status. After changing the posts to any of the default built-in statuses, it worked. But doesn't work for custom statuses it seems.... at least not with custom statuses created with a plugin called PublishPress.. Perhaps it just doesn't work with custom statuses at all, all-around

Hope this can help someone else!

本文标签: Issue with CPT posts within WP REST API showing as