One of the most frequently used features in WordPress (I judge by myself and by the themes I’ve worked with). It’s strange that I’m only describing it on my blog now.
get_option( $option, $default = false )
If the option with the specified name doesn’t exist and the $dafault parameter isn’t specified, the function will return false.
If the option is stored as a serialized string in the database, it will be decoded with maybe_unserialize() when returned.
Scalar non-string values will be converted to strings, e.g:
false option value will be returned as string(0) “”,
true will be returned as string(1) “1”,
0 will be returned as string(1) “0”,
1 will be returned as string(1) “1”;
(string) The name of the option whose value we want to retrieve. We can either take the name of one of the standard WordPress options listed below , or we can find it out ourselves, I also told you how.
(number|string|array|object) If you want to get some option on the site that doesn’t exist, then get_option() either returns false or whatever is specified in this second parameter.
WordPress standard options #
By “standard,” I mean those options that already exist on the pure WordPress engine, most of them accessible through the Settings menu.
I’ve listed them below, pre-dividing them into categories. In order to get any of them using get_option() function, you just need to pass the name of the option you want in the function, for example to get admin email we can use the code line $email = get_option(‘admin_email’ );
Options – General #
Option name Description
admin_email (line) Admin email address.
blogdescription (string) A brief description of the site. Defaults to: __(‘Just another WordPress blog’) If this line raises questions for you, read my lesson on site localization.
blogname (string) Site name.
users_can_register (integer) Whether the registration on the site is open. May have values 1 – open, 0 – closed (default).
default_role (string) The role assigned to new users when registering to the site. The default is subscriber.
WPLANG (string) Site language. In the format of the locale ru_RU, where ru – specifies the Russian language and RU – the country. For example en_GB where en is English and GB is country in ISO 3166-1 Alpha-2 format
gmt_offset (Integer) The number in hours that the website time is different from Greenwich Mean Time (GMT), e.g. in Moscow it is 3 (GMT+3).
timezone_string (string) The time zone of the site, e.g. Europe/Moscow
date_format (string) The date format to be used by default on the website with functions like the_date(), get_the_date(), the_modified_date(), etc. The default is F j, Y. Note, however, that the date will be translated. For example F j, Y will correspond to January 3, 2022.
time_format (string) The default time format that will be used on the site by functions such as the_time(), get_the_time(), the_modified_time(), etc. The default is g:i a, after translation it will be for example 12:44 pp (pp is after noon).
start_of_week (integer) The first day of the week. Can take values:
0 – Sunday
1 – Monday
2 – Tuesday
3 – Wednesday
4 – Thursday
5 – Friday
6 – Saturday
siteurl (string) The URL where WordPress is installed can be obtained with site_url().
home (string) The URL of the site itself, you can get with home_url().
Options – Write #
Option name Description
Use_smilies (Integer) Convert emoticons like 🙂 and 😛 into pics. 0 – no, 1 – yes (default).
use_balanceTags (integer) WordPress should fix incorrect XHTML code automatically. 0 – no (default), 1 – yes.
default_category (integer) The default rubric that will be assigned to posts if no rubric is added to them. Also, this rubric cannot be deleted.
default_post_format (string) The default format of entries.
mailserver_url (string) Mail server for publishing via e-mail.
mailserver_port (Integer) Port
mailserver_login (string) Login
mailserver_pass (password) Password
default_email_category (integer) The default rubric for mail publication.
ping_sites update services.
Options – Read #
Option name Description
show_on_front (string) What is selected as the display on the home page of the site, can take only two values: posts (your last posts), page (static page).
page_on_front (integer) The ID of the page to display on the home page.
page_for_posts (integer) ID of the page which will be the blog page.
posts_per_page (integer) How many posts to display on one blog page. It is also the default value for displaying any posts in loops.
posts_per_rss (integer) How many posts to display in RSS.
rss_use_excerpt (string) In the RSS feed, display an excerpt or full text.
blog_public (integer) Ask search engines not to index the site, 1 – ask
Translated with www.DeepL.com/Translator (free version)
A WordPress Commenter
Hi, this is a comment.
To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
Commenter avatars come from Gravatar.