Simple understanding of the use of update_option () functions in WordPress development, wordpressgetoption_php Tutorial

Source: Internet
Author: User
Tags autoload deprecated import database

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.