[Resolved] Custom View to output xml / json / serialize data instead of HTML
The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 10 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
I created a custom types fields that is needed for an app. And this field will server as an API of an app. What I need is that I can output a raw xml /json / serialize data based from the customs fields I have on wp-types.
What should my approach here? If I am to create a php file which directory shall I save it?
For example, you can create a separate php file with this code in it:
//see that we have a post id
$id = intval($_GET['id']);
if (empty($id)) die("Please provide a post id");
//get all custom fields for the post
$data = get_post_custom($id);
//send back as json data
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.