get_options()
Gets the values of several WordPress options.
Options missing from the cache are loaded from the database in a single query. Each option is then processed by get_option().
No Hooks.
Returns
array.
array- pairs of option name and value. A nonexistent option usually has the valuefalse.
Usage
get_options( $options );
- $options(string[]) (required)
- Names of the options to retrieve.
Examples
#1 Getting several options
$options = get_options( [ 'blogname', 'blogdescription', 'posts_per_page', ] ); echo esc_html( $options['blogname'] );
Changelog
| Since 6.4.0 | Introduced. |
get_options() get options code WP 7.1
function get_options( $options ) {
wp_prime_option_caches( $options );
$result = array();
foreach ( $options as $option ) {
$result[ $option ] = get_option( $option );
}
return $result;
}