Join Roy Sivan for an in-depth discussion in this video Adding custom data to the API response and displaying it, part of AngularJS and WordPress: Building a Single-Page Application.
- Great, now we have a basic blog, including both a listing…and detail page, but what if you want more data…from your posts to be available in the post object,…in either the List or Detail pages?…You want to use that within in the ngRepeat loop…that we created.…There is a way with the JSON Rest API…to easily modify the response using php.…So, I'm going to go into Sublime,…I'm going to open up the functions.php file…and the first thing we're going to do…is tell the API that we want to register a new field.…I'm going to call my function register_new_field.…
We're going to call on the register_ap_field function,…which is built into the API,…and we're only going to need it for the post for now,…so let's just use the post, and if you have any other urls…or endpoints that you create for the API,…this is where you would change that…but since we only need post objects…and we're only using the post url endpoint,…I'm just going to use posts.…So, I'm going to call my new field my_awesome_field…and now I need to pass an array, so we've got callback.…
In this course, Roy Sivan shows how to build a single-page web app with WordPress, AngularJS, and the WordPress REST API plugin. Roy also reviews creating controllers and routes to get a basic understanding of building a multiview single-page app. Plus, get some tips to transition your single-page app to a native mobile app with AppPresser.
- Setting up WordPress
- Creating the AngularJS components, including the controller and route
- Connecting WordPress and AngularJS
- Connecting views
- Adding and displaying custom data
- Using a plugin to show advanced custom field (ACF) data on the template