2

OK so stick with me on this one... it's a little involved. I won't describe it all, I'll simplify things as best I can to the basics.

OK so, on my wordpress site I have three text boxes (BOX1,BOX2,BOX3). These need to display specific numbers, that are brought in live from a Google Sheets table. If the table gets updated, these boxes need to update immediately (on page refresh). I have this working already using this, which means all I need to do is put a shortcode into each text box, and it automatically displays the right data. Which is working fine... except that I actually have about 20 of these boxes, and google has a limit of 10 API calls per second. So a page refresh takes several seconds.

An alternative is to simply embed or autofill a Tablepress or similar table, and grab the entire Google Sheets table with one request. But these tables can only be formatted -as- tables, which isn't what I want.

So what I would LIKE to do (but which may not be possible), is to somehow change this into two steps = 1. Use a single shortcode or other trigger to grab the entire Google Sheets table in a single API call. (or at least grab 1 entire field per call, if splitting it up makes step 2 easier, it'd still mean only 3 calls instead of 20). 2. Then use seperate shortcodes (or whatever) in each text box like I am now, to select what cell's data appears in which box.

I suspect the answer may lie in some kind of... grabbing the Sheets data into Arrays, and then parsing the arrays with calls that show "item1" or "item5". The data will always be in a consistent order, so I guess this might work. I have zero idea how it might be done though, and I'm not sure how you'd grab the data from Sheets.

Hence being here, just to see if there's a method or solution that is escaping me. I'm suspecting I won't get any replies lol, but worth a try.

  • Welcome to WordPress Development. I hope you find the answer(s) you are looking for. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. – Matthew Brown aka Lord Matt Oct 6 '19 at 17:12
  • An API may provide many ways to access it, just by changing the url. For example, developers.google.com/sheets/api/quickstart/php shows how to select a range of cells. – adelval Oct 6 '19 at 18:08
  • 1
    Sounds like your idea of pulling everything in with one API call is the way to go. This is more of a Google Sheets API question though as it stands. Might get more traction here if you update your question with your current progress and add specific questions about where you're stuck making it integrated WordPress. – Dave Romsey Nov 1 '19 at 17:21

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.