WordPress.org

Ready to get started?Download WordPress

Codex

zh-cn:get option

Contents

描述

一种从数据库中获得数据的函数。如果想要获得的数据不存在或者没有相关的值,将会返回“FALSE”。


用法

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

变量

$show
(string) (required) 获取选项的名称。 可用默认选项列表请参考此处: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

返回值

返回值可以是各种类型。

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

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