Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

get_option()

3 tags 1 category

get_option() — Retrieves an option value based on an option name. If the option does not exist, and a default value is not provided, boolean false is returned. This could be used to check whether you need to initialize an option during installation of a plugin, however that can be done better by using add_option() which will not overwrite existing options. Not initializing an option and using boolean false as a return value is a bad practice as it triggers an additional database query. The type of the returned value can be different from the type that was passed when saving or updating the option.

Inputs: $option (string): Name of the option to retrieve. Expected to not be SQL-escaped. $default_value (mixed): Optional. Default value to return if the option does not exist.

Returns mixed: Value of the option. A value of any type may be returned, including scalar (string, boolean, float, integer), null, array, object. Scalar and null values will be returned as strings as long as they originate from a database stored option value. If there is no option in the database, boolean false is returned.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…