WordPress REST API & Adding Custom Endpoints with Alpine JS

Category : Knowledge Share

With WordPress REST, we can create custom endpoints with any query and information we want. This helps organize that data for filtering or easier HTML development. We pass parameters on the query string and get different JSON results using those parameters.

Through Alpine JS we can use the JSON result from the REST API to load the results on the webpage without having to reload the webpage itself. This creates a more streamlined user experience.

For resources and examples of the end product filtering data functions, see the links and images below!

https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints

https://github.com/alpinejs/alpine

Apartment Store Webpage Example

Apartment Store JSON Example