get_bloginfo( string $show = '', string $filter = 'raw' ): string
- Since
- 0.71
- Source
wp-includes/general-template.php:1018
Retrieve site info with get_bloginfo(): the site title, tagline, URL, WordPress version, language, charset, or feed URLs, selected by the $show argument. With no argument it returns the site name; pass 'display' as the second argument when echoing so the bloginfo filters run.
Description
Possible values for $show include:
- 'name' - Site title (set in Settings > General)
- 'description' - Site tagline (set in Settings > General)
- 'wpurl' - The WordPress address (URL) (set in Settings > General)
- 'url' - The Site address (URL) (set in Settings > General)
- 'admin_email' - Admin email (set in Settings > General)
- 'charset' - The "Encoding for pages and feeds" (set in Settings > Reading)
- 'version' - The current WordPress version
- 'html_type' - The Content-Type (default: "text/html"). Themes and plugins can override the default value using the 'pre_option_html_type' filter
- 'text_direction' - The text direction determined by the site's language. is_rtl() should be used instead
- 'language' - Language code for the current site
- 'stylesheet_url' - URL to the stylesheet for the active theme. An active child theme will take precedence over this value
- 'stylesheet_directory' - Directory path for the active theme. An active child theme will take precedence over this value
- 'template_url' / 'template_directory' - URL of the active theme's directory. An active child theme will NOT take precedence over this value
- 'pingback_url' - The pingback XML-RPC file URL (xmlrpc.php)
- 'atom_url' - The Atom feed URL (/feed/atom)
- 'rdf_url' - The RDF/RSS 1.0 feed URL (/feed/rdf)
- 'rss_url' - The RSS 0.92 feed URL (/feed/rss)
- 'rss2_url' - The RSS 2.0 feed URL (/feed)
- 'comments_atom_url' - The comments Atom feed URL (/comments/feed)
- 'comments_rss2_url' - The comments RSS 2.0 feed URL (/comments/feed)
Some $show values are deprecated and will be removed in future versions.
These options will trigger the _deprecated_argument() function.
Deprecated arguments include:
- 'siteurl' - Use 'url' instead
- 'home' - Use 'url' instead
Compatibility
- WordPress
- since 0.71
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$showstringoptional- Site info to retrieve. Default empty (site name).Default:
'' $filterstringoptional- How to filter what is retrieved. Default 'raw'.Default:
'raw'
Return value
string- Mostly string values, might be empty.
Code examples
Every example is editable and runs in a real WordPress booted in your browser by WordPress Playground. Press Run, then edit the code: clicking away re-runs it. Nothing is sent anywhere until you do.
Print the site name and tagline in a header
Fetch the title and tagline with the 'display' filter when the values are going straight into markup.
$site_name = get_bloginfo( 'name', 'display' );
$tagline = get_bloginfo( 'description', 'display' );
printf(
'<a class="site-brand" href="%s">%s</a> <span class="tagline">%s</span>',
esc_url( home_url( '/' ) ),
esc_html( $site_name ),
esc_html( $tagline )
);'siteurl' and 'home' are deprecated $show values and trigger _deprecated_argument(); use 'url' for the site address and 'wpurl' for the WordPress install address, which differ when core lives in a subdirectory.
Performance profile
How much work a call to get_bloginfo() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Moderate
- Scaling
- Constant
- Instructions
- 9–89
- Plugin surface
- 2 hooks
- Called by
- 50
Reads stored settings via get_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 217.
Third-party callbacks on 'bloginfo_url', 'bloginfo' run inside this call, and their cost is not bounded by anything here.
50 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - cacheobject cache
wp_cache_get()one call below get_bloginfo() - serializeserialisation
maybe_unserialize()one call below get_bloginfo()
Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 26 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_bloginfo() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$filter !== "display" | 9–49 | none |
$filter !== "display" | 10–16 | home_url() |
$filter !== "display" | 10–35 | site_url() |
$filter !== "display" | 10–56 | get_option() |
$filter !== "display" | 10–36 | get_stylesheet_uri() |
$filter !== "display" | 10–38 | get_stylesheet_directory_uri() |
$filter !== "display" | 10–42 | get_template_directory_uri() |
$filter !== "display" | 11–33 | get_feed_link() |
$output !== "html_lang_attribute" && !$output && $filter !== "display" | 14–56 | __() |
$filter === "display" | 17–61 | apply_filters() |
$filter === "display" | 18–28 | home_url(), apply_filters() |
$filter === "display" | 18–47 | site_url(), apply_filters() |
14 further outcomes, up to 89 instructions
$filter === "display" | 18–68 | get_option(), apply_filters() |
$filter === "display" | 18–48 | get_stylesheet_uri(), apply_filters() |
$filter === "display" | 18–50 | get_stylesheet_directory_uri(), apply_filters() |
$filter === "display" | 18–54 | get_template_directory_uri(), apply_filters() |
$filter === "display" | 19–45 | get_feed_link(), apply_filters() |
$filter !== "display" | 19–63 | __(), determine_locale() |
$output !== "html_lang_attribute" && !$output && $filter === "display" | 22–68 | __(), apply_filters() |
$filter !== "display" | 26–30 | __(), sprintf(), _deprecated_argument(), home_url() |
$filter === "display" | 27–75 | __(), determine_locale(), apply_filters() |
!function_exists() && $filter !== "display" | 28–72 | __(), sprintf(), _deprecated_argument(), function_exists() |
function_exists() && $filter !== "display" | 32–77 | __(), sprintf(), _deprecated_argument(), function_exists(), is_rtl() |
$filter === "display" | 34–42 | __(), sprintf(), _deprecated_argument(), home_url(), apply_filters() |
!function_exists() && $filter === "display" | 36–84 | __(), sprintf(), _deprecated_argument(), function_exists(), apply_filters() |
function_exists() && $filter === "display" | 40–89 | __(), sprintf(), _deprecated_argument(), function_exists(), is_rtl(), apply_filters() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 217 | 9–89 | 32 | |
| 8.5 | 217 | 9–89 | 32 | |
| 8.4 | 217 | 9–89 | 32 | 15 fewer instructions than PHP 8.3 |
| 8.3 | 232 | 9–98 | 32 | |
| 8.2 | 232 | 9–98 | 32 | |
| 8.1 | 232 | 9–98 | 32 | |
| 7.4 | 232 | 9–98 | 32 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while get_bloginfo() runs, in this order:
- apply_filters( bloginfo_url )filterline 1140 (+122 into the body)
Filters the URL returned by get_bloginfo().
- apply_filters( bloginfo )filterline 1150 (+132 into the body)
Filters the site information returned by get_bloginfo().
Uses · 13
- _deprecated_argument()Marks a function argument as deprecated and inform when it has been used.
- __()Retrieves the translation of $text.
- home_url()Retrieves the URL for the current site where the front end is accessible.
- site_url()Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
- get_option()Retrieves an option value based on an option name.
- get_feed_link()Retrieves the permalink for the feed type.
- get_stylesheet_uri()Retrieves stylesheet URI for the active theme.
- get_stylesheet_directory_uri()Retrieves stylesheet directory URI for the active theme.
- get_template_directory_uri()Retrieves template directory URI for the active theme.
- determine_locale()Determines the current locale desired for the request.
- is_rtl()Determines whether the current locale is right-to-left (RTL).
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
Show all 13
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 50
- TwentyTwenty_Non_Latin_Languages::get_non_latin_css()Gets custom CSS.
- WP::send_headers()Sends additional HTTP headers for caching, content type, etc.
- WP_Automatic_Updater::send_debug_email()Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
- WP_Automatic_Updater::send_email()Sends an email upon the completion or failure of a background core update.
- WP_Customize_Media_Control::to_json()Refresh the parameters passed to the JavaScript via JSON.
- WP_Customize_Nav_Menu_Item_Setting::js_value()Prepares the value for editing on the client.
- WP_Customize_Nav_Menus::customize_register()Adds the customizer settings and controls.
- WP_Customize_Nav_Menus::load_available_items_query()Performs the post_type and taxonomy queries for loading available menu items.
- WP_Customize_Nav_Menus::search_available_items_query()Performs post queries for available-item searching.
- WP_Customize_Panel::json()Gather the parameters passed to client JavaScript via JSON.
- WP_Customize_Section::json()Gather the parameters passed to client JavaScript via JSON.
- WP_Customize_Site_Icon_Control::content_template()Renders a JS template for the content of the site icon control.
Show all 50
- WP_Customize_Widgets::enqueue_scripts()Enqueues scripts and styles for Customizer panel and export data to JavaScript.
- WP_Debug_Data::get_wp_core()Gets the WordPress core section of the debug data.
- WP_Http::request()Send an HTTP request to a URI.
- WP_Links_List_Table::get_primary_column_aria_label()Returns a clean label for the primary (Name) column's row header `aria-label`.
- WP_MS_Sites_List_Table::get_primary_column_aria_label()Returns a clean label for the primary (URL) column's row header `aria-label`.
- WP_Media_List_Table::get_primary_column_aria_label()Returns a clean label for the primary (File) column's row header `aria-label`.
- WP_Plugin_Install_List_Table::display_rows()Generates the list table rows.
- WP_Plugin_Install_List_Table::prepare_items()
- WP_Privacy_Policy_Content::get_default_content()Returns the default suggested privacy policy content.
- WP_REST_Templates_Controller::get_wp_templates_author_text_field()Returns a human readable text for the author of the template.
- WP_REST_URL_Details_Controller::get_remote_url()Retrieves the document title from a remote URL.
- WP_REST_URL_Details_Controller::prepare_metadata_for_output()Prepares the metadata by: - stripping all HTML tags and tag entities.
- WP_REST_Widget_Types_Controller::get_widgets()Normalize array of widgets.
- WP_Recovery_Mode_Email_Service::get_debug()Return debug information in an easy to manipulate format.
- WP_Script_Modules::get_src()Gets the versioned URL for a script module src.
- WP_Widget_Meta::widget()Outputs the content for the current Meta widget instance.
- WP_Widget_Text::is_legacy_instance()Determines whether a given instance is legacy and should bypass using TinyMCE.
- _WP_Editors::default_settings()Returns the default TinyMCE settings.
- _access_denied_splash()Displays an access denied message when a user tries to view a site's dashboard they do not have access to.
- _fix_attachment_links()Replaces hrefs of attachment anchors with up-to-date permalinks.
- _print_emoji_detection_script()Prints inline Emoji detection script.
- _wp_get_entity_view_config_posttype_wp_template()Provides the view configuration for the `wp_template` post type.
- admin_created_user_email()
- bloginfo()Displays information about the current site.
- cache_javascript_headers()Sets the HTTP headers for caching for 10 days with JavaScript content type.
- core_update_footer()Returns core update footer message.
- export_wp()Generates the WXR export file for download.
- feed_links()Displays the links to the general feeds.
- feed_links_extra()Displays the links to the extra feeds such as category feeds.
- fetch_feed()Builds SimplePie object based on RSS or Atom feed from URL.
- filter_SSL()Formats a URL to use https.
- get_bloginfo_rss()Retrieves RSS container for the bloginfo function.
- get_custom_logo()Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
- get_index_rel_link()Get site index relational link.
- get_language_attributes()Gets the language attributes for the 'html' tag.
- get_oembed_response_data()Retrieves the oEmbed response data for a given post.
- get_pagenum_link()Retrieves the link for a page number.
- get_post_embed_html()Retrieves the embed code for a specific post.
Source code
function get_bloginfo( $show = '', $filter = 'raw' ) { switch ( $show ) { case 'home': // Deprecated. case 'siteurl': // Deprecated. _deprecated_argument( __FUNCTION__, '2.2.0', sprintf( /* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument. */ __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ), '<code>' . $show . '</code>', '<code>bloginfo()</code>', '<code>url</code>' ) ); // Intentional fall-through to be handled by the 'url' case. case 'url': $output = home_url(); break; case 'wpurl': $output = site_url(); break; case 'description': $output = get_option( 'blogdescription' ); break; case 'rdf_url': $output = get_feed_link( 'rdf' ); break; case 'rss_url': $output = get_feed_link( 'rss' ); break; case 'rss2_url': $output = get_feed_link( 'rss2' ); break; case 'atom_url': $output = get_feed_link( 'atom' ); break; case 'comments_atom_url': $output = get_feed_link( 'comments_atom' ); break; case 'comments_rss2_url': $output = get_feed_link( 'comments_rss2' ); break; case 'pingback_url': $output = site_url( 'xmlrpc.php' ); break; case 'stylesheet_url': $output = get_stylesheet_uri(); break; case 'stylesheet_directory': $output = get_stylesheet_directory_uri(); break; case 'template_directory': case 'template_url': $output = get_template_directory_uri(); break; case 'admin_email': $output = get_option( 'admin_email' ); break; case 'charset': $output = get_option( 'blog_charset' ); if ( '' === $output ) { $output = 'UTF-8'; } break; case 'html_type': $output = get_option( 'html_type' ); break; case 'version': global $wp_version; $output = $wp_version; break; case 'language': /* * translators: Translate this to the correct language tag for your locale, * see https://www.w3.org/International/articles/language-tags/ for reference. * Do not translate into your own language. */ $output = __( 'html_lang_attribute' ); if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {Changelog
Introduced in 0.71. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/general-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.