WordPress Options API get_option


get_option function is used to retrieve a value from from options table based on option name.

You can use the following code to get email address of a WordPress site administrator.

<?php echo get_option('admin_email'); ?>

get_option() has an optional 2nd argument, which allows you to set a default value to return in the case that the requested option isn't set. By default, this argument is false.

To retrieve a text string, and use a boilerplate string if the text isn't set in the options table, you could do this:

<?php get_option( 'my_text', "I don't have anything written. Yet." ); ?>