From the course: WordPress: REST API
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Add fields to the response - WordPress Tutorial
From the course: WordPress: REST API
Solution: Add fields to the response
(upbeat techno music) - Welcome back. Hopefully you were able to solve this challenge, and even if you didn't, I'm pretty sure you have a good idea of what you need to do. You just couldn't get the pieces to fit right in the time I gave you. So let me walk you through how I solved this challenge. In the example plug-in provided with the exercise files, we already have a field registered. You'll remember, it's this one, catlinks. So when I want to register additional fields, all I need to do is grab the entire register rest field function, copy it, and then just paste it below, give the new field a new name, so previous_post_ID, and then call a new callback function; so, in this case, RDP_get_previous_post_ID. Then I just did the same three times for the three new fields I want to create So we have previous_post_ID, previous_post_title, and previous_post_link. All right. Then I need to create these callback…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.