WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!


share|improve this question
up vote 1 down vote accepted

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

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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