Successfully reported this slideshow.
Your SlideShare is downloading. ×

Let's code: extending the WP REST API - modifying responses

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Using the WP REST API
Using the WP REST API
Loading in …3
×

Check these out next

1 of 9 Ad

Let's code: extending the WP REST API - modifying responses

Download to read offline

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. By default, it provides REST endpoints (URLs) representing the posts, pages, taxonomies, and other built-in WordPress data types. Your application can send and receive JSON data to these endpoints to query, modify and create content on your site. However, it is also possible to extend the WP REST API, in order to perform specific actions that are outside of the scope of the default routes and endpoints. In this session, you will learn about one of the ways you can extend the WP REST API, by modifying REST responses.

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. By default, it provides REST endpoints (URLs) representing the posts, pages, taxonomies, and other built-in WordPress data types. Your application can send and receive JSON data to these endpoints to query, modify and create content on your site. However, it is also possible to extend the WP REST API, in order to perform specific actions that are outside of the scope of the default routes and endpoints. In this session, you will learn about one of the ways you can extend the WP REST API, by modifying REST responses.

Advertisement
Advertisement

More Related Content

Similar to Let's code: extending the WP REST API - modifying responses (20)

Advertisement

Recently uploaded (20)

Let's code: extending the WP REST API - modifying responses

  1. 1. Jonathan Bossenger Let’s Code Learn.WordPress.org Extending the WP REST API - modifying responses
  2. 2. 2 👋🏽 Welcome! As you join, please make sure you have your local development environment ready: • A local WordPress installation • A code editor like VSCode or Sublime • The example plugin • https://github.com/jonathanbossenger/wp- learn-rest-api/releases/download/0.0.4/wp- learn-rest-api.0.0.4.zip • Postman https://www.postman.com/downloads/ Then, let everyone know in the chat where you’re joining us from… Hello! ○ My name is Jonathan Bossenger ○ From Cape Town, South Africa ○ Ex-developer turned code instructor ○ Sponsored contributor at Automattic ○ jonathanbossenger.com
  3. 3. Learn.WordPress.org Let's code! The WP REST API - modifying responses Jonathan Bossenger
  4. 4. Announcements ○ Welcome, and thank you to Mark for co-hosting! ○ We are presenting in focus mode, but please feel free to enable your video. ○ Please let me know if you can’t see this slide. ○ You are welcome to ask questions. ○ You are welcome to post questions in the chat, or unmute to ask questions.
  5. 5. Announcements ○ Make sure your local install is ready • https://github.com/jonathanbossenger/wp-learn-rest- api/releases/download/0.0.4/wp-learn-rest-api.0.0.4.zip • https://www.postman.com/downloads/ ○ If I am going too fast, please let me know! ○ We will be posting this session to https://wordpress.tv/ afterwards ○ For more WordPress focused content please visit https://learn.wordpress.org/ ○ Follow up questions/feedback - https://github.com/WordPress/Learn/issues/1283
  6. 6. Learning Outcomes 1. Learn the different ways to add custom fields to the WP REST API 2. Enable custom meta fields for a WP REST API route 3. Add custom top level fields to a WP REST API route 4. Learn about REST API schema
  7. 7. Objectives 1. Setup and review the example plugin code so far 2. Set up and test some API routes using Postman 3. Enable a custom field using register_meta 4. Add a custom field using register_rest_field 5. Add field schema to the custom field 7
  8. 8. 8 Let’s code.
  9. 9. Resources ○ https://github.com/WordPress/Learn/issues/1283 ○ https://github.com/jonathanbossenger/wp-learn-rest-api/releases/download/0.0.4/wp-learn-rest- api.0.0.4.zip ○ https://www.postman.com/downloads/ ○ https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ ○ https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_fields ○ https://developer.wordpress.org/reference/functions/register_meta/ ○ https://developer.wordpress.org/reference/functions/register_rest_field/

Editor's Notes

  • TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.

×