Your JavaScript frontend needs a list of featured products from WordPress. Not the whole REST API surface, not raw post objects with forty fields, just the ten items the homepage carousel shows, shaped the way the frontend wants them.
The endpoint is ten minutes of work: query, map, return. The question that eats the rest of the afternoon: where does that code go?
Where custom endpoints live today
functions.php. Fastest to write, tied to your theme. Switch themes, lose the endpoint. Two years later it's line 1400 of a file nobody wants to scroll.
A site-specific plugin. The clean classic answer. But now your ten minutes of logic come wrapped in a plugin header, a hook, and a registration array:






