Skip to content

Instantly share code, notes, and snippets.

@dongilbert
Created June 4, 2012 18:53
Show Gist options
  • Save dongilbert/2870164 to your computer and use it in GitHub Desktop.
Save dongilbert/2870164 to your computer and use it in GitHub Desktop.
Shortcode for WP Option Tree
<?php
/**
* Shortcode to go along with my Option Tree
* helper functions. See those here:
* https://gist.github.com/2627998
*
* <samp>[theme_option name="home_text"]</samp>
*
* @param array Array of attributes passed from the shortcode.
* @return string|null
*/
if(function_exists('get_theme_option')
{
add_shortcode('theme_option', 'theme_option_shortcode');
function theme_option_shortcode($atts)
{
extract(shortcode_atts(array(
'name' => null
), $atts));
if($name !== null)
{
$name = get_theme_option($name);
}
return $name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment