Exercise 1: Why /wp-json/wp/v2/portfolio Returns an Error — Possible Solution ==================================================================== WHAT'S MISSING ------------------------------ The show_in_rest argument, set to true, is missing from the register_post_type() call. WHY THIS CAUSES THE ERROR, PER THIS CHAPTER'S OWN WARNING ------------------------------ Per this chapter, "show_in_rest defaults to false... Forgetting this argument is a genuine, common source of confusion: the post type works perfectly in the dashboard and on the front end, yet /wp-json/wp/v2/portfolio simply doesn't exist until it's explicitly enabled." The WordPress Intermediate/Advanced 4 version of the code never included show_in_rest at all, which means it defaulted to false - the post type was registered correctly for every other purpose (the dashboard, the theme's own templates), but was never exposed as a REST API endpoint in the first place. WHY THE POST TYPE OTHERWISE WORKING "PERFECTLY" MAKES THIS CONFUSING ------------------------------ Because register_post_type() succeeded, and the portfolio post type behaves correctly everywhere else - in the WordPress admin, in the template hierarchy from WordPress Intermediate/Advanced 2 - there's no obvious signal anywhere in the dashboard suggesting REST API access was never enabled. A developer reasonably expecting "if the post type exists, its REST endpoint should exist too" would have no clear reason to suspect a single missing argument is the actual cause. THE FIX ------------------------------ Add 'show_in_rest' => true to the same arguments array already used in WordPress Intermediate/Advanced 4's register_post_type() call, exactly as this chapter's own example shows. Once added, WordPress will automatically expose the corresponding /wp-json/wp/v2/portfolio endpoint without any further code needed. WHY THIS WORKS AS AN ANSWER ------------------------------ It identifies the precise missing argument, cites this chapter's own explicit warning about the default value and its confusing symptom, and supplies the concrete fix consistent with this chapter's own example code.