Skip to main content
added 6 characters in body
Source Link
Volomike
  • 1.9k
  • 2
  • 18
  • 20

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/staff

When I use /staff, it shows me the core post fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

How do I get a given staff member's custom field properties on their record? I can access someone such as:

https://example.com/wp-json/wp/v2/staff/john-smithhttps://example.com/wp-json/wp/v2/staff/?slug=john-smith

...but there are no custom fields in there that I attached to this record.

How do I use the REST API to get the custom fields attached to a custom post type?

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/staff

When I use /staff, it shows me the core post fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

How do I get a given staff member's custom field properties on their record? I can access someone such as:

https://example.com/wp-json/wp/v2/staff/john-smith

...but there are no custom fields in there that I attached to this record.

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/staff

When I use /staff, it shows me the core post fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

How do I get a given staff member's custom field properties on their record? I can access someone such as:

https://example.com/wp-json/wp/v2/staff/?slug=john-smith

...but there are no custom fields in there that I attached to this record.

How do I use the REST API to get the custom fields attached to a custom post type?

deleted 76 characters in body
Source Link
Volomike
  • 1.9k
  • 2
  • 18
  • 20

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/member

...although I don't know why I can't use...

https://example.com/wp-json/wp/v2/staff

...which returns a 404 response in JSON. When I use the /member approachstaff, it shows me some of the core post fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

  1. How do I get a list of staff members via the API?
  2. Once I get a staff member URL from the previous call, then how do I get its full data, including custom fields?

How do I get a given staff member's custom field properties on their record? I can access someone such as:

https://example.com/wp-json/wp/v2/staff/john-smith

...but there are no custom fields in there that I attached to this record.

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/member

...although I don't know why I can't use...

https://example.com/wp-json/wp/v2/staff

...which returns a 404 response in JSON. When I use the /member approach, it shows me some of the fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

  1. How do I get a list of staff members via the API?
  2. Once I get a staff member URL from the previous call, then how do I get its full data, including custom fields?

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/staff

When I use /staff, it shows me the core post fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

How do I get a given staff member's custom field properties on their record? I can access someone such as:

https://example.com/wp-json/wp/v2/staff/john-smith

...but there are no custom fields in there that I attached to this record.

Source Link
Volomike
  • 1.9k
  • 2
  • 18
  • 20

How To Read Read Custom Post Type Data in Headless CMS Mode

I'm doing my site with two pieces -- the headless CMS on a subdomain where content is entered, and the root domain where I display data. Only WP is installed in the subdomain, not the root domain. In the subdomain, I created a custom post type called Staff, and then items inside are a Member. I noticed that I can't use the URL...

https://example.com/wp-json/wp/v2/posts

(WP REST API)

...to read these items. Looking in the docs, I see that I can address it as...

https://example.com/wp-json/wp/v2/member

...although I don't know why I can't use...

https://example.com/wp-json/wp/v2/staff

...which returns a 404 response in JSON. When I use the /member approach, it shows me some of the fields, but not any of the custom field groups. (Note, I'm using the Custom Post Types plugin from TotalPress.org.)

  1. How do I get a list of staff members via the API?
  2. Once I get a staff member URL from the previous call, then how do I get its full data, including custom fields?