I’m writing a plugin to manage the display of some resources accessed via a REST API.
I’ve set up some rewrite rules to get the correct parameters to send via the API, and some shortcodes that retrieve the data and display the views. But I feel like this is not a good way to do it.
For example I have this rewrite rule:
/object/param1/param2/param3
And the shortcode in that page use param1
, param2
and param3
to call a specific endpoint and build the page.
What do you think of this approach? Could it be improved in some way?
Thank you for your inputs.
Update (after suggestion by TheDeadMedic)
In particular, as an example, I felt there was something wrong when I had to create a dynamic title for each object. The title in WordPress is built before the content is parsed (in my case, before the shortcode made the call to the API). So I added a filter to request
to parse the request, make the request to the API, save it somewhere and pass it to the shortcode.
As a first step, I’d like to streamline this process in some way.