Thank you for this snippet, I've been looking for something similar for a while. I was trying a different approach with fetch or Promise, but I hadn't got lucky until I found your snippet.
I would like to ask you a suggestion about how to change a little bit the code, instead of having a previous and a next button, I would like to create a pagination. I did a project on my github account with the wordpress API and vanilla javascript, but I built in PHP (so essentially I created a query in sql and then I return a json file from it, and I used ajax to retrieve the data and have a super fast pagination of my post, or really any kind of route you can built with the wordpress-api).
I've been using react since a couple of months, and I found it very challenging.
In any case, I would like to change this behavior:
Page {page} of {nrofpages}
I would like to map the nrofpages variable so I can create a markup (
${i}
) but I'm pretty sure it won't work, so I was trying to figure it out what could be the best approach to create a pagination for this component.
If you want to have a look at the plugin that I create for wordpress, here's the link:
Dear Stephan,
Thank you for this snippet, I've been looking for something similar for a while. I was trying a different approach with fetch or Promise, but I hadn't got lucky until I found your snippet.
I would like to ask you a suggestion about how to change a little bit the code, instead of having a previous and a next button, I would like to create a pagination. I did a project on my github account with the wordpress API and vanilla javascript, but I built in PHP (so essentially I created a query in sql and then I return a json file from it, and I used ajax to retrieve the data and have a super fast pagination of my post, or really any kind of route you can built with the wordpress-api).
I've been using react since a couple of months, and I found it very challenging.
In any case, I would like to change this behavior:
Page {page} of {nrofpages}
I would like to map the nrofpages variable so I can create a markup (
- ${i}
) but I'm pretty sure it won't work, so I was trying to figure it out what could be the best approach to create a pagination for this component.If you want to have a look at the plugin that I create for wordpress, here's the link:
github.com/orso081980/Track-email-....
Please let me know what is your thought regarding it and thank you in advance for your answer!
Hey Marco,
Thanks for you kind feedback. :)
As for your Question... Could you send me a DM on Twitter @vanaf1979 ? I might be able to help you out.
Cheers,
Stephan