Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shortcode to retrieve a theme option within a post
/**
* Get option shortcode
*
* Make it easy to add theme options within posts. Example usage:
* [get-theme-option key="contact_telephone"]
*
* @param array $theme_option Shortcode key/values
* @return string The value returned by get_option()
*/
function iweb_get_option_shortcode( $theme_option ) {
return get_option( $theme_option['key'] );
}
add_shortcode( 'get-theme-option', 'iweb_get_option_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.