I'm in the process of converting my existing WordPress site to use Preact/Redux on the frontend and use the WP REST API to get post data back from the admin.
I'll be using React Router and a rewrite in .htaccess to rewrite the URLs to the index.html file, and React Router should handle the requests.
Given an existing URL of https://peteschuster.com/2017/10/high-praise-react-react-ecosystem/
I assume I'll setup my route as /:year/:month/:slug
My question is, how would I use those params to get the post ID so I can call the REST endpoint for: GET /wp/v2/posts/<id>
?
Perhaps there is another way to achieve this? I tried several combinations of:
https://peteschuster.com/wp/v2/posts/2017/10/high-praise-react-react-ecosystem/
to no avail. I was thinking it might be possible similar to how /feed
is handled like:
https://peteschuster.com/2017/10/high-praise-react-react-ecosystem/json
Any guidance would be greatly appreciated. Thanks!