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:


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.

  • This is a very open, opinion-based question. I understand there's always the hesitation of "is this the right way", but what about when there is no "right" way? Perhaps you could narrow the scope of what concerns you/post some code you're unsure of/elaborate on your setup. – TheDeadMedic Apr 3 '14 at 13:14
  • Thank you @TheDeadMedic. I've updated the question with a specific example :) – Jubstuff Apr 3 '14 at 13:28
  • Please show us some code and tell where you got stuck. Currently it's too vague to get answered. – kaiser Apr 3 '14 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.