Codex

Function Reference/get option

Contents

Description

A safe way of getting values for a named option from the options database table. If the desired option does not exist, or no value is associated with it, FALSE will be returned.


Usage

 <?php echo get_option$show$default ); ?> 

Parameters

$show
(string) (required) Name of the option to retrieve. A list of valid default options can be found at the Option Reference.
Default: None
$default
(mixed) (optional) The default value to return if no value is returned (ie. the option is not in the database).
Default: false

Return Values

Mixed values for the option.

Values

More information: Option_Reference

Examples

Show Blog Title

Displays your blog's title in a <h1> tag.

 <h1><?php echo get_option('blogname'); ?></h1> 

Show Character Set

Displays the character set your blog is using (ex: UTF-8)

 <p>Character set: <?php echo get_option('blog_charset'); ?> </p> 

Retrieve Administrator E-mail

Retrieve the e-mail of the blog administrator, storing it in a variable.

 <?php $admin_email get_option('admin_email'); ?> 

Changelog

  • since 1.5.0

Source Code

get_option() is located in wp-includes/functions.php.

Related

Options API: get_option(), add_option(), update_option(), delete_option()

See also index of Function Reference and index of Template Tags.