Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 at 13:14
    
Thank you @TheDeadMedic. I've updated the question with a specific example :) –  JustB Apr 3 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 at 13:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.