這個 get_option 用的很廣泛,幾乎大部份的程式都會有用到。我要用的是這一個範例:
Retrieve Administrator E-mail
Retrieve the e-mail of the blog administrator, storing it in a variable.
1
|
<?php $admin_email = get_option( 'admin_email' ); ?> |
WordPress 官方文件:
https://developer.wordpress.org/reference/functions/get_option/
get_option( string $option, mixed $default = false )
Description #Description
If the option does not exist or does not have a value, then the return value will be false. This is useful to check whether you need to install an option and is commonly used during installation of plugin options and to test whether upgrading is required.
If the option was serialized then it will be unserialized when it is returned.
Any scalar values will be returned as strings. You may coerce the return type of a given option by registering an ‘option_$option’ filter callback.
Parameters #Parameters
- $option
-
(string) (Required) Name of option to retrieve. Expected to not be SQL-escaped.
- $default
-
(mixed) (Optional) Default value to return if the option does not exist.
Default value: false
Return #Return
(mixed) Value set for the option.
Source #Source
File: wp-includes/option.php
More Information #More Information
A concise list of commonly-used options is below, but a more complete one can be found at the Option Reference.
'admin_email'
– E-mail address of blog administrator.'blogname'
– Weblog title; set in General Options.'blogdescription'
– Tagline for your blog; set in General Options.'blog_charset'
– Character encoding for your blog; set in Reading Options.'date_format'
– Default date format; set in General Options.'default_category'
– Default post category; set in Writing Options.'home'
– The blog’s home web address; set in General Options.'siteurl'
– WordPress web address; set in General Options.
Warning: This is not the same asget_bloginfo( 'url' )
(which will return the homepage url), but asget_bloginfo( 'wpurl' )
.'template'
– The current theme’s name; set in Presentation.'start_of_week'
– Day of week calendar should start on; set in General Options.'upload_path'
– Default upload location; set in Miscellaneous Options.'users_can_register'
– Whether users can register; set in General Options.'posts_per_page'
– Maximum number of posts to show on a page; set in Reading Options.'posts_per_rss'
– Maximum number of most recent posts to show in the syndication feed; set in Reading Options.
There are many more options available, a lot of which depend on what plugins you have installed.