WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Function Reference/update option"

(Added links to Option Reference)
(Using Parameter template)
Line 23: Line 23:
   
 
== Parameters ==
 
== Parameters ==
  +
{{Parameter|$name|string|Name of the option to update. A list of valid default options to update can be found at the [[Option Reference]].}}
  +
{{Parameter|$value|string|Value for this option name. You can find possible values for the default options at the [[Option Reference]].|optional|''Empty''}}
  +
{{Parameter|$description|string|Descriptive text for the option. The description can be used in backend labels.|optional|''Empty''}}
  +
{{Parameter|$autoload|string|Should this option be automatically loaded? Valid values: '''yes''' or '''no'''.|optional|yes}}
   
; name : (''string'') Name of the option. Underscores separate words, lowercase only - this is going to be in a database. A list of valid default options can be found at the [[Option Reference]].
 
; value : (''string'') Value for this option name. Defaults to the empty string. You can find possible values for the default options at the [[Option Reference]].
 
; description : (''string'') Descriptive text for the option. Can be used in backend labels. Defaults to the empty string.
 
; autoload : (''string'') Is this to option be automatically loaded? Possible values: yes or no. Defaults to "yes".
 
 
[[Category:New page created]]
 
 
[[Category:Functions]]
 
[[Category:Functions]]
 
 
{{Copyedit}}
 
{{Copyedit}}

Revision as of 02:13, 13 January 2008

Description

A safe way of updating or adding a named option/value pair to the options database table. The indata is escaped with $wpdb->escape before the INSERT statement.

This function can be called even if the option does not exist, the function will create the option.

See add_option for more information.

Usage

<?php update_option($name, $value = '', $description = '', $autoload = 'yes'); ?>

Example

Usage

<?php update_option("myhack_extraction_length", '255', 
'Max length of extracted text in characters.', 'yes'); ?>

Parameters

$name
(string) (required) Name of the option to update. A list of valid default options to update can be found at the Option Reference.
Default: None
$value
(string) (optional) Value for this option name. You can find possible values for the default options at the Option Reference.
Default: Empty
$description
(string) (optional) Descriptive text for the option. The description can be used in backend labels.
Default: Empty
$autoload
(string) (optional) Should this option be automatically loaded? Valid values: yes or no.
Default: yes
This article is marked as in need of editing. You can help Codex by editing it.