Skip to content

Instantly share code, notes, and snippets.

@gregrickaby
Created July 2, 2013 13:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gregrickaby/5909416 to your computer and use it in GitHub Desktop.
Save gregrickaby/5909416 to your computer and use it in GitHub Desktop.
Get custom options from WordPress database
/**
* Create helper function to easily get options from database
*
* @since Child 1.0
*/
function child_get_option( $key, $setting = null ) {
$setting = $setting ? $setting : 'child_options'; // this must match your custom options in the database.
$options = get_option( $setting );
return is_array( $options[$key] ) ? stripslashes_deep( $options[$key] ) : stripslashes( wp_kses_decode_entities( $options[$key] ) );
}
// Usage
$my_option = child_get_option( 'some_option' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment