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

Within one plugin file I have several calls to the same option in the database via get_option(). Does WordPress do a database query every time I use get_option()? Would it be better to get the option once and store it in a global variable?

share|improve this question
this answer explains how options work. – Milo Feb 21 '13 at 3:02
possible duplicate of Plugin options autoloading – s_ha_dum Feb 21 '13 at 5:17
up vote 0 down vote accepted

Wordpress will only do a database lookup the first time if the option hasn't been auto-loaded or already accessed prior. The performance hit is negligible, however if you're loading multiple separate options with a bunch of get_options instead of using the serialised option functionality, then the initial lookup * X number of separate option rows could potentially cause performance issues.

In your other question which is a duplicate of this one, I answer the question with an example of best practice code if you're concerned with get_option performance here.

share|improve this answer

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.