I've written a plugin which retrieves product info from the Amazon Product Advertising API via shortcode. When I retrieve the results from Amazon, I'm storing each individual product in a transient so that I don't need to make that particular call again. On most pages of my site which use this shortcode, it's only for a single product. But but in the case of one particular page I’m getting a TooManyRequests response because I'm using the shortcode 20 or 30 times.
The Amazon API allows me to pass in multiple products at a time, but I’m not sure how I could do that given I’m using multiple occurrences of a plugin.
Here's an example of how I'm calling the plugin right now.
[mm-productlinking id="1" template="image"]
Is there any way to collect multiple shortcode uses before execution, then call all of them at the same time? Perhaps something like this?
[mm-productlinking-group]
some html code here
[mm-productlinking id="1" template="image"]
more html code here
[mm-productlinking id="2" template="image"]
and even more html code
[/mm-productlinking-group]
If I did something like this, I'd want it to be optional so that I wasn't forced to include the mm-productlinking-group outer shortcode.
Thoughts?
Thanks to Emiel for the direction, this is what I came up with.
It can be called like this
In which case I do the following:
It can also be called like this in which case the group functionality is not used.
I'd love some thoughts on this approach as I've never done it before.