From the course: WordPress: REST API

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Challenge: Add fields to the response

Challenge: Add fields to the response - WordPress Tutorial

From the course: WordPress: REST API

Start my 1-month free trial

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,…

Contents