Home WordPress General Functions get_bloginfo() WordPress get_bloginfo() Function Definition In WordPress, get_bloginfo() returns a piece of site information as a string. It takes the same $show values as bloginfo() , such as name, description, url, charset, version, and language.
Use it when you want to keep the value in a variable, join it with other text, or pass it to another function.
Syntax Call it and store or echo the result.
<?php
$name = get_bloginfo( 'name' );
echo $name; Call What it does get_bloginfo( 'name' )Returns the site title. get_bloginfo( 'version' )Returns the WordPress version. get_bloginfo( 'name', 'display' )Returns the title ready for safe display.
Want to print right away? bloginfo() is shorter.
Full declaration get_bloginfo( string $show = '', string $filter = 'raw' ): string Parameters Parameter Description $showstring. What to return, for example name, description, url, wpurl, charset, version, language. Default is empty (the site title). $filterstring. raw (default) returns the value as stored. display runs display filters, such as escaping.
Return Value Return Value Description string The requested site information.
Important
Escape when you print. The default filter is raw, so the value is not escaped. When you print it inside HTML, wrap it with esc_html(), or use bloginfo() which prepares it for display.
WordPress Examples Three short theme examples. Each one shows the code and what it prints.
1. Echo the site name 2. Join with other text 3. Show the WordPress version Example 1 — Echo the site name Escape the value before printing.
<p>© <?php echo esc_html( get_bloginfo( 'name' ) ); ?></p> How It Works get_bloginfo( 'name' ) returns the site title.esc_html() makes it safe for HTML.echo prints the final text.Example 2 — Join with other text Build a sentence in a variable.
<?php
$text = 'Welcome to ' . get_bloginfo( 'name' )
. ' - ' . get_bloginfo( 'description' );
echo esc_html( $text ); Welcome to My Blog - Just another WordPress site How It Works Both values are returned as strings. The dot joins the strings together. The final text is escaped and printed. Example 3 — Show the WordPress version Useful on a status page or in a comment.
<?php
$version = get_bloginfo( 'version' );
echo 'Running WordPress ' . $version; How It Works version returns the installed WordPress version.We store it in $version. Then we print a short message. Frequently Asked Questions What does get_bloginfo() return? It returns the requested site information as a string, such as the name, tagline, URL, or version.
What is the difference between get_bloginfo() and bloginfo()? get_bloginfo() returns the value. bloginfo() prints it.
What does the second parameter do? raw returns the value as stored. display applies display filters such as escaping.
Which show values can I use? Common ones are name, description, url, wpurl, charset, version, language, admin_email, and stylesheet_url.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
11 people found this page helpful
Helpful Share Copy link Suggestion