This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_option/
Languages: English • Español • Italiano • 日本語 Русский • Tiếng Việt • 中文(简体) • (Add your language)
A safe way of getting values for a named option from the options database table. If the desired option does not exist, or no value is associated with it, FALSE will be returned.
<code style="color: #000000"> <span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">get_option</span><span style="color: #007700">( </span><span style="color: #0000BB">$option</span><span style="color: #007700">, </span><span style="color: #0000BB">$default </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span> </code>
A concise list of valid options is below, but a more complete one can be found at the Option Reference.
<code style="color: #000000"><span style="color: #0000BB"><?php $no_exists_value </span><span style="color: #007700">= </span><span style="color: #0000BB">get_option</span><span style="color: #007700">( </span><span style="color: #DD0000">'no_exists_value' </span><span style="color: #007700">); </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">$no_exists_value </span><span style="color: #007700">); </span><span style="color: #FF8000">/* outputs false */ </span><span style="color: #0000BB">$no_exists_value </span><span style="color: #007700">= </span><span style="color: #0000BB">get_option</span><span style="color: #007700">( </span><span style="color: #DD0000">'no_exists_value'</span><span style="color: #007700">, </span><span style="color: #DD0000">'default_value' </span><span style="color: #007700">); </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">$no_exists_value </span><span style="color: #007700">); </span><span style="color: #FF8000">/* outputs 'default_value' */ </span><span style="color: #0000BB">?></span></code>
Displays your blog's title in a <h1> tag.
<code style="color: #000000"> <h1><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">get_option</span><span style="color: #007700">( </span><span style="color: #DD0000">'blogname' </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span></h1> </code>
Displays the character set your blog is using (ex: UTF-8)
<code style="color: #000000"> <p>Character set: <span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">get_option</span><span style="color: #007700">( </span><span style="color: #DD0000">'blog_charset' </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span> </p> </code>
Retrieve the e-mail of the blog administrator, storing it in a variable.
<code style="color: #000000"> <span style="color: #0000BB"><?php $admin_email </span><span style="color: #007700">= </span><span style="color: #0000BB">get_option</span><span style="color: #007700">( </span><span style="color: #DD0000">'admin_email' </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span> </code>
get_option() is located in wp-includes/option.php.