Created
May 7, 2012 14:10
-
-
Save dongilbert/2627998 to your computer and use it in GitHub Desktop.
Helper functions for WP Option Tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Paste this code in your theme's functions.php | |
* file and wherever you normally would call | |
* `get_option_tree('option-name');`, use | |
* `get_theme_option('option-name');` instead. | |
* This will pass through the already retrieved | |
* global $option_tree (called when your theme loads) | |
* and save you from several additional database | |
* calls on a single page request. | |
* | |
* Update: I created a shortcode to access the | |
* settings within a post/page. | |
* https://gist.github.com/2870164 | |
*/ | |
if(function_exists('get_option_tree')) | |
{ | |
global $option_tree; | |
$option_tree = get_option('option_tree'); | |
function theme_option($id) | |
{ | |
echo get_theme_option($id); | |
} | |
function get_theme_option($id) | |
{ | |
global $option_tree; | |
return get_option_tree($id, $option_tree); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment