From the course: WordPress: Custom Post Types and Taxonomies

Unlock the full course today

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

Activating the REST API on your post type

Activating the REST API on your post type - WordPress Tutorial

From the course: WordPress: Custom Post Types and Taxonomies

Start my 1-month free trial

Activating the REST API on your post type

- One of the arguments we haven't set yet is for the REST API which should get some special attention. Aside from allowing our post type data to be accessible from outside WordPress via an API, there's another crucial feature that the REST API turns on. If we look at the post edit screen for creating a new business right now, you'll see the classic editor. The one that existed pre 5.0. The other feature that's included in the REST API support is enabling the new block or Gutenberg editor. Let's go ahead and do that now. If we reference the Code X and we scroll down towards the bottom we'll see a key called show_in_rest. There are also two other rest related arguments for rest base and rest controller class. But we will definitely leave those at the default. So let's go ahead and copy the show_in_rest key which is set by default to false. Then we'll go back to our code and under the supports key, we'll paste in show_in_rest and we'll set it to true. If we save our file and then go back…

Contents