WordPress Options API

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

Options are pieces of data that WordPress uses to store various preferences and configuration settings. 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.

Syntax

  • // Create new option within WordPress
    add_option( $option, $value = , $deprecated = , $autoload = 'yes' );

  • // Removes an option from the database.
    delete_option( $option );

  • // Retrieve a saved option
    get_option( $option, $default = false );

  • // Update the value of an option that was already added.
    update_option( $option, $newvalue );

  • // There are also *_site_option() versions of these functions,
    // to manipulate network-wide options in WordPress Multisite

  • // Create new network option
    add_site_option( $option, $value = , $deprecated = , $autoload = 'yes' );

  • // Removes a network option
    delete_site_option( $option );

  • // Retrieve a saved network option
    get_site_option( $option, $default = false );

  • // Update the value of an option that was already added.
    update_site_option( $option, $newvalue );

Remarks

The Options API is a simple and standardized way of working with data staored in the options table of MySQL database. The API makes it easy to create, read, update, and delete options.



Got any WordPress Question?