Function and usage of bloginfo() in wordpress


Answers ( 1 )


    The bloginfo() function in WordPress is a powerful tool used to display information about the current site. This function is commonly utilized in WordPress themes to retrieve and display various types of data related to the site. Here's a detailed explanation of its functionality and usage:


    bloginfo( string $show = '' )


    • Displays information about the current site.


    • bloginfo() is used to output information about your WordPress site, such as the site's name, description, URL, stylesheet directory, and more.
    • It's a simple and efficient way to access and display various pieces of site data without having to delve into the WordPress database.
    • This function directly echoes the information to the page. Therefore, it's typically used within the HTML of WordPress theme files.


    • $show (string, optional): Specifies the type of site information to display. The default value is an empty string (''), but there are various options you can use, which are detailed below.

    Common $show Values:

    1. 'name': Site title (set in Settings > General).
    2. 'description': Site tagline or description (set in Settings > General).
    3. 'wpurl': WordPress address (URL) (set in Settings > General).
    4. 'url': Site address (URL) (set in Settings > General).
    5. 'admin_email': Admin email (set in Settings > General).
    6. 'stylesheet_url': Primary stylesheet URL (usually style.css of the current theme).
    7. 'stylesheet_directory': Directory path of the current theme's stylesheet.
    8. 'template_directory': Template directory URL of the current theme.
    9. 'atom_url': Atom feed URL.
    10. 'rss2_url': RSS2 feed URL.

    Sample Usage:

    <!DOCTYPE html>
        <meta charset="<?php bloginfo('charset'); ?>">
        <title><?php bloginfo('name'); ?> - <?php bloginfo('description'); ?></title>
        <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
            <h1><?php bloginfo('name'); ?></h1>
            <p><?php bloginfo('description'); ?></p>
        <!-- More HTML and PHP code -->

    In this example, bloginfo() is used to:

    • Set the character encoding with charset.
    • Dynamically generate the page's title using the site's name and description.
    • Link to the site's primary stylesheet.
    • Display the site's name and tagline in the header section.


    • For a full list of possible $show values, it's recommended to refer to the WordPress Codex or Developer Resources.
    • If you need to retrieve information without echoing it, consider using get_bloginfo() instead.

Leave an answer