Skip to content

WordPress’ Bloginfo Explained

One of the most useful template tags you’ll use in WordPress is bloginfo. As the name suggests, it lets you dynamically show information about your blog. That’s the important bit. Your blog. So when you’re designing a [theme] for public release, you can accommodate for all sort of different situations.

So what can I use bloginfo for?

All sorts of different things. Here’s the complete list, courtesy of the codex. It doesn’t make too much sense on it’s own if you don’t already know what you’re doing, so I’ve added in a little explanation below each.

admin_email = admin@example

Email of the administrator.

atom_url = http://example/home/feed/atom

Atom feed URL

charset = UTF-8

The character ecoding system (not particularily interesting – used in the ).

comments_atom_url = http://example/home/comments/feed/atom

Atom feed for all comments on the blog.

comments_rss2_url = http://example/home/comments/feed

RSS feed for all comments on the blog.

description = Just another WordPress blog

The description (or tagline) of your blog, as set under ‘Settings’ in the backend.

url = http://example/home

Homepage of the blog.

html_type = text/html

Type of HTML used (again, not too interesting :P).

language = en-GB

Language used on the blog.

name = Testpilot

Name or title of your blog, as set under ‘Settings’ in the backend.

pingback_url = http://example/home/wp/xmlrpc.php

URL to which pingbacks should be sent.

rdf_url = http://example/home/feed/rdf

a general method for conceptual description or modeling of information that is implemented in web resources; using a variety of syntax formats.

via Wikipedia

rss2_url = http://example/home/feed

RSS feed for the blog.

rss_url = http://example/home/feed/rss

URL of the RSS feed.

siteurl = http://example/home

URL of the site.

stylesheet_directory = http://example/home/wp/wp-content/themes/largo

Directory where the style.css file is located, should be used for child theme.

stylesheet_url = http://example/home/wp/wp-content/themes/largo/style.css

URL of the stylesheet.

template_directory = http://example/home/wp/wp-content/themes/largo

Directory of your theme.

template_url = http://example/home/wp/wp-content/themes/largo

URL of the theme.

text_direction = ltr

Direction in which the text reads (ie left to right).

version = 2.8.5

Version of WordPress the blog is running.

wpurl = http://example/home/wp

URL of the WordPress installation (sometimes different to where the homepage is).

When should bloginfo be used?

Good question. It should be used for ‘stuff’ that is unique to your installation of WordPress (for example the title or homepage). Let’s say we want to send a link to the homepage. On your installation it’s at /word/, but on mine it’s at /press/! You want to share the theme you’re using with me, so obviously I’m going to have to change all the links to the homepage, right? Not true. Using the siteurl parameter, the homepage URL can be dynamically generated. So instead of links reading:

<a href="/word/">Homepage</a>

They should be:

<a href="<?php bloginfo('siteurl'); ?>Homepage</a>

That format applies to all uses of bloginfo :

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

Further examples

Stylesheet URL. On my installation it’s /press/wp-content/themes/Biblioteca/style.css but on yours it’s /word/wordpress-installed-in-a-different-directory-to-the-homepage/wp-content/themes/Biblioteca/style.css. Bloginfo to the rescue again – instead of:

<link rel="stylesheet" href="/press/wp-content/themes/Biblioteca/style.css" type="text/css" media="screen,projection" />

You can dynamically generate the stylesheet URL:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen,projection" />

The final example I’ll do today is the title. On my blog it’s Press! but on yours it’s Word! Using the name parameter we can dynamically generate the title:

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

And with that, we’re done. Enjoy your new-found knowledge!

Yay! 🎉 You made it to the end of the article!
Alex Denning

Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Thomas Scholz
December 6, 2009 9:18 am

‘stylesheet_directory’ and ‘template_directory’ point to different places if you use a child theme. ‘template_directory’ gives you the path to the parent theme, ‘stylesheet_directory’ to the child. Lousy names, in my opinion.

‘charset’ is useful for forms: You should use it for the accept-charset attribute to avoid mixed encodings.

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

Would love your thoughts, please comment.x

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

20 Best Free WordPress Themes for 2024 (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...