WordPress REST API

WordPress REST API Introduction

The WordPress REST API lets other programs talk to your site with HTTP requests, and the answer comes as JSON. A mobile app, a JavaScript front end (React, Vue), another website or…

WordPress REST API: Get Posts

The posts route /wp-json/wp/v2/posts is the one used most. This chapter shows how to list, filter and page through posts. Let us make some sample content first: List posts The newest post…

WordPress REST API Authentication and Create Posts

Reading public posts needs no login, but to create, change or delete anything, or to see private data, the API must know who you are. WordPress has two main ways to do…

WordPress REST API Custom Endpoint

The built in routes cover posts, pages and more, but often you need your own: send a contact request, return a special list, or run a calculation. With register_rest_route() you can add…

WordPress REST API: Post Comments

The REST API has a route for comments: /wp-json/wp/v2/comments. You can list the comments of a post and send a new one from a front end like a React or mobile app….

WordPress REST API: Navigation Menu Items

A headless site (a React or Vue front end with WordPress as the back end) needs the menu of WordPress too. WordPress has routes for menus, menu items and menu locations. Let…