I'm using an API which is accessed with ID/Secret, etc. and use it in different widgets. In each widget however, I'm repeating the entire JSON process (i.e. file_get_contents, decode, etc.). I can't help but think this must be slowing the entire process down.

What would be the best way of going about only calling this API once and then grabbing various data from it in different widgets, theme components, etc.?

Thank you!



Use Transients API - http://codex.wordpress.org/Transients_API

I would also suggest you to use WordPress HTTP API - http://codex.wordpress.org/HTTP_API instead of file_get_contents

  • Thanks for that Ashfame! Good stuff, I'll check into it all. – Noel Tock Mar 20 '11 at 20:03
  • Happy to help! :) – Ashfame Mar 20 '11 at 20:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.