Overview
The Options API is a simple and standardized way of storing data in the database. The API makes it easy to create, access, update, and delete options. All the data is stored in the wp_options table under a given custom name.
This page contains the technical documentation needed to use the Options API. A list of default options can be found in the Option Reference (link to Codex version, waiting for content migration to HelpHub).
Note that the _site_ functions are essentially the same as their counterparts. The only differences occur for WP Multisite, when the options apply network-wide and the data is stored in the wp_sitemeta table under the given custom name.
Function Reference
Add/Delete Option:
Get/Update Option:
Examples
// Create an option to the database
add_option( $option, $value = , $deprecated = , $autoload = 'yes' );
// Removes option by name.
delete_option( $option );
// Fetch a saved option
get_option( $option, $default = false );
// Update the value of an option that was already added.
update_option( $option, $newvalue );
Available options by category
Discussion
blacklist_keys: When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so “press” will match “WordPress.”
Default: NULL
Data type:String (possibly multi-line)comment_max_links: Hold a comment in the queue if it contains the value of this option or more.
Default: 2
Data type:Integercomment_moderation: Before a comment appears, an administrator must always approve the comment.
1 : Yes
0 : False (default)
Data type:Integercomments_notify: E-mail me when anyone posts a comment.
1 : Yes (default)
0 : No
Data type:Integerdefault_comment_status: Allow comments (can be overridden with individual posts)
open : Allow comments (default)
closed : Disallow comments
Data type:Stringdefault_ping_status: Allow link notifications from other blogs (pingbacks and trackbacks).
open : Allow pingbacks and trackbacks from other blogs (default)
closed : Disallow pingbacks and trackbacks from other blogs
Data type:Stringdefault_pingback_flag: Attempt to notify any blogs linked to from the article (slows down posting).
1 : Yes (default)
0 : No
Data type:Integermoderation_keys: When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the moderation queue. One word or IP per line. It will match inside words, so “press” will match “WordPress.”
Default: NULL
Data type:String (possibly multi-line)moderation_notify: E-mail me when a comment is held for moderation.
1 : Yes (default)
0 : No
Data type:Integerrequire_name_email: Before a comment appears, the comment author must fill out his/her name and email.
1 : Yes (default)
0 : No
Data type:Integerthread_comments: Enable WP-native threaded (nested) comments.
1 : Yes
0 : No (default)
Data type:Integerthread_comments_depth: Set the number of threading levels for comments.
1 thru
10 : levels
Default: 5
Data type:Integershow_avatars: Avatar Display
1 : (default) Show Avatars
0 : Do not show Avatars
Data type:Integeravatar_rating: Maximum Rating
G : (default) Suitable for all audiences
PG : Possibly offensive, usually for audiences 13 and above
R : Intended for adult audiences above 17
X : Even more mature than above
Data type:Stringavatar_default: Default Avatar
mystery : (default) Mystery Man
blank : Blank
gravatar_default : Gravatar Logo
identicon : Identicon (Generated)
wavatar : Wavatar (Generated)
monsterid : MonsterID (Generated)
retro : Retro (Generated)
Data type:Stringclose_comments_for_old_posts: Automatically close comments on old articles
1 : Yes
0 : No (default)
Data type:Integerclose_comments_days_old: Automatically close comments on articles older than x days
Default: 14
Data type:Integershow_comments_cookies_opt_in: Show the cookies opt-in checkbox on the comment form and enable comment cookies
1 : Yes (default as of 4.9.8)
0 : No
Data type:Integerpage_comments: Break comments into pages
1 : Yes (default)
0 : No
Data type:Integercomments_per_page:
Default: 50
Data type:Integerdefault_comments_page:
Default: ‘newest’
Data type:Stringcomment_order:
asc : (default)
desc :
Data type:Stringcomment_whitelist: Comment author must have a previously approved comment
1 : Yes (default)
0 : No
Data type:
General
admin_email