Skip Navigation

[Gelöst] Automatically adding custom fields to REST API

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

Once I set up the Custom Post Type to be exposed via the REST API I expect the associated Post Field Group fields to be exposed as well

Solution:

The client have been found a workaround with another plugin "WP REST API Controller":

https://wordpress.org/plugins/wp-rest-api-controller/

Relevant Documentation:

This support ticket is created vor 5 Jahre, 9 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 Antworten, has 3 Stimmen.

Last updated by chrisH-10 vor 5 Jahre, 9 Monate.

Assisted by: Luo Yang.

Author
Artikel
#923817

Tell us what you are trying to do?
Once I set up the Custom Post Type to be exposed via the REST API I expect the associated Post Field Group fields to be exposed as well, but they are not.
I have been creating a custom plugin to expose fields as I add them, but this tedious.
(a) are you working on a solution for this?
(b) I'm happy to write a more generic plugin, but I didn't have any luck finding a function in the Codex for getting all the fields of a Custom Post Type. Clearly you know how to do this. Could you enlighten me or provide a snippet?

Is there any documentation that you are following?
No, could not find any.

#923943

Hello,

You are right, there isn't such a built-in feature within Types plugin, and it has been reported lots of time, for example:
https://toolset.com/forums/topic/rest-api-update-custom-fields/
https://toolset.com/forums/topic/exposing-custom-fields-through-rest-api/
https://toolset.com/forums/topic/how-to-get-custom-fields-into-the-rest-api-output/

We hope to include support for these in a future release, but I don't have an ETA for you right now. if you agree, we can mark this thread as a feature request, and let our team know it's important for you!

#923947
#924054

Thanks Luo, stellar support as always!

That stackexchange article has a link to https://wordpress.org/plugins/wp-rest-api-controller/ which appears to be the plugin I was looking to create, how awesome!

The other support links you provided were old, closed and contain many a "hidden link", so I figured I'd ask again. There seem to have been a lot of requests for this. For my needs the REST API Controller plugin does what I need. You may want to evaluate that and perhaps endorse/contribute to it.

If you do build this into Types I would expect to see a checkbox on the field create/edit UI where I can check a box to add it to REST. I would also hope for a PHP filter so I can transform the output for the field.

Thanks!

#1169566

what's on the hidden link?
how to update custom fields using rest api?

#1169800

I think it was a link to a Stack Exchange article. What you want is the plugin I referenced. It's actively maintained and allows you to add your custom fields to the REST API with a UI.

https://wordpress.org/plugins/wp-rest-api-controller/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.