What is bloginfo()?

  • bloginfo() is a WordPress template tag that displays (or returns) basic information about your site, such as:
    • Site title
    • Tagline
    • URL
    • Stylesheet URL
    • Description
  • This info comes from your WordPress Settings (Dashboard → Settings → General, etc.).

Syntax

<?php bloginfo( $show ); ?>
  • $show → parameter that defines what information you want (string).

You can also use:

<?php echo get_bloginfo( $show ); ?>

(get_bloginfo() returns the value instead of directly echoing it.)


Common Parameters of bloginfo()

Here are the most frequently used ones:

ParameterWhat it outputs
'name'Site title (from Settings → General)
'description'Tagline / site description
'url'Home URL (same as home_url())
'wpurl'WordPress installation URL
'stylesheet_url'Full URL of the current theme’s style.css
'stylesheet_directory'Path to the current theme’s folder
'template_url' or 'template_directory'Parent theme directory URL
'admin_email'Admin email (from Settings)
'version'Current WordPress version
'language'Site language (e.g., en-US)
'charset'Character encoding (UTF-8)

Examples

1. Display Site Title:

<?php bloginfo( 'name' ); ?>

2. Display Tagline:

<?php bloginfo( 'description' ); ?>

3. Add Stylesheet in <head>:

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>">

4. Get Home URL:

<a href="<?php bloginfo( 'url' ); ?>">Home</a>

5. Show Charset:

<meta charset="<?php bloginfo( 'charset' ); ?>">

Difference between bloginfo() and get_bloginfo()

  • bloginfo()prints the info directly.
  • get_bloginfo()returns the info (useful inside PHP variables or concatenations).

Example:

<title><?php echo get_bloginfo( 'name' ) . ' - ' . get_bloginfo( 'description' ); ?></title>

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *