Simply understand the use of the Update_option () function in WordPress development, Wordpressgetoption
function Introduction
Update_option () is used to update the option values that exist in the data table. This function can replace add_option, but is less flexible than add_option. Update_option checks and determines whether the option already exists. If it does not exist, add the option with Add_option (' option_name ', ' option_value '). Unless the user needs to specify an option parameter for Add_option, Update_option () is a dual-use function that can add and update options at the same time.
Note: update_option () cannot be updated when wp_load_alloptions will load (or not load) an option. In this case, you should use delete_option after you use the Update_option () function.
function usage
<?php update_option ($option _name, $newvalue);?>
function parameters
$option _name
(string) (required) the option name that needs to be updated. The valid default options that can be upgraded are listed in option reference.
Default value: None
$newvalue
(mixed) (required) The new value of the current option name. The new value can be a string, an array, an object, or a serialized value.
Default value: None
function instance
Update the value of the option name myhack_extraction_length to 255. If this option is not present, use the Add_option function to set the value of AutoLoad to No.
<?php$option_name = ' myhack_extraction_length '; $newvalue = ' 255 '; if (Get_option ($option _name)) { update_option ($option _name, $newvalue);} else { $deprecated = '; $autoload = ' no '; Add_option ($option _name, $newvalue, $deprecated, $autoload); }?>
source file
Update_option () is located in wp-includes/option.php.
Articles you may be interested in:
- Get database field content and add theme settings menu in WordPress
- How to solve the problem that occurs when using the WordPress $wpdb class to read MySQL database to do Ajax
- The WordPress Import Database appears "Unknown collation: ' Utf8mb4_unicode_ci" error resolution
http://www.bkjia.com/PHPjc/1091106.html www.bkjia.com true http://www.bkjia.com/PHPjc/1091106.html techarticle simply understand the use of the Update_option () function in WordPress development, the Wordpressgetoption function introduces Update_option () to update the option values that exist in the data table. This function can replace add_opt ...