From the course: WordPress: REST API
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Challenge: Add fields to the response - WordPress Tutorial
From the course: WordPress: REST API
Challenge: Add fields to the response
(upbeat music) - [Instructor] Time for another challenge. This time I want you to take what you've learned about adding new fields to the REST API, and add some more fields. Here's what I want you to do specifically. Using the example plugin provided in the exercise files, add three new fields to the post object with information about the previous posts. I want the previous post ID, the previous post title, and the previous post link. Here's a tip to get you started. Getting the previous post is a common thing theme developers do all the time, and there is probably an existing function that allows you to query the previous post and get old information. You need to get that previous post object in PHP, pull out the pieces you need, and return them to new REST API fields. And you have to set up several fields here. Got it? Okay. Pause this movie, take a crack at this challenge, spend no more than five minutes on it,…
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.