Getting options is easy and done with a single function call:
Always use the code above inside WordPress hooks that run on or after
after_setup_theme For example:
For meta box options, you can optionally include a post ID of a page or post to get their values (can be helpful when creating your own post loops). This is optional, if no post ID is given, the post ID of the current loop will be used:
The value type that you get may differ depending on the option’s
type. For example, a
text option returns a string; a
select-googlefont option returns an array containing data of the selected font.
The Do’s & Don’ts
- DO use
after_setup_themeWordPress hook. Any other hooks that run after it are also acceptable – e.g.
wp_enqueue_scriptsDO use getOption straight from your theme’s template files – e.g. single.php, index.php, archive.php.
- DO use
getOptionstraight from your theme’s template files – e.g. single.php, index.php, archive.php.
- DON’T use getOption directly from your functions.php outside a hook (or any non-template script without a hook for that matter). Doing so will give out errors since Titan Framework has not initialized yet.
- DON’T use
functions.phpoutside a hook (or any non-template script without a hook for that matter). Doing so will give out errors since Titan Framework has not initialized yet.
v1.2.2, the postID was required.[/zilla_alert]