options in wordpress

options is safe way of adding a named option and value in the options database table. It does nothing if the option already exists. After the option is saved, it can be accessed with get_option(), changed with update_option(), and deleted with delete_option() and add with add_option().

You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is inserted into the database. You can create options without values and then add values later.

Calling add_option first checks whether the option has already been added, and returns false if an option with the same name exists. Next, it checks to make sure the option name is not one of the protected names alloptions or notoptions, and dies with an error message if attempting to overwrite a protected option. If the option name is not protected, and does not already exist, the option will be created.

Below is Example for Understand how its works.

Suppose our option Name is developer


Delete a single option

This will delete ‘developer’ from the options table within your MySQL database.


I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

50 + = 56

%d bloggers like this: