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

Is it possible to add a token to any wp-option that could be replaced on get where the token being defined in a plugin’s option or the configure file?

http://[[[env_token]]].sitename.com/some-page.html => 
http://staging.sitename.com/some-page.html or 
http://dev.sitename/some-page.html or 

To be more specific I am managing a Wordpress instance inside a development life cycle where I often copy production data down to staging and development servers. Often the options tables are unmanageable and have changed since the last dump. However, after analyzing what the most frequent changes are between servers I noticed it is the environmental specific tokens like dev and staging.

I am a little concerned with running a string replace on every option get, but I am making use of page, data, and object caching.

share|improve this question
up vote 2 down vote accepted

See the filter reference on the codex. In particular, note that you can use the form option_$foo to filter just a specific option key. So if you wanted a filter specific to the siteurl option, you could do:

add_filter( 'option_siteurl', 'my_url_filter' );
share|improve this answer
Additionally, the filter 'pre_option_' . $option exists. E.g. pre_option_siteurl – Jonnybojangles Aug 15 '11 at 23:43

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.