Get your options

In your theme

Goodbye get_option. Welcome get_option

There are two ways to access to the stored options:

  • the classical get_option Wordpress function which needs the option name as a parameter (read the doc ;))
  • the new get_option TeaThemeOptions function which has been upgraded to use the transient API if asked.

Get option in the theme

Instead of using get_option, you can use:

<?php

$my_value = TeaThemeOptions::get_option('my_value', 'default_value');

But writing TeaThemeOptions::get_option is pretty long, right? That's why we suggest you to add these lines in your functions.php, after the Tea Theme Options declaration:

<?php

function _get_option($option, $default = '', $transient = false)
{
    return TeaThemeOptions::get_option($option, $default, $transient);
}

You can now access to your options through:

<?php

$my_value = _get_option('my_value', 'default_value');