Set your options

Only if needed!

The missing set_option

There are two ways to set options in your DB:

  • update_option or add_option Wordpress function which have different uses (read the add_option and the update_option references)
  • the new set_option TeaThemeOptions function which uses the transient API if asked and store options in DB without autoload.

Set option from the theme

Simply, use the function as follow:

<?php

$my_new_value = 'a new value';
TeaThemeOptions::set_option('my_value', $my_new_value);

In the same way, writing TeaThemeOptions::set_option is too long. So we suggest you to add these lines in your functions.php, after the Tea Theme Options declaration:

<?php

function _set_option($option, $value, $transient = false)
{
    TeaThemeOptions::set_option($option, $value, $transient);
}

You can now set your options:

<?php

$my_new_value = 'a new value';
_set_option('my_value', $my_new_value);