WordPress 3.0 New Template Tags for Home and Admin URLs

I love when template tags get shorter, don’t you? Whereas previously we might use bloginfo(‘url’) or get_option(‘site_url’), WordPress 3.0 has some new template tags:

The new home_url template tag retrieves the home url for the current site. Here’s the default way to use it:

1
<?php home_url(); ?>

Check out more variants on home_url in the codex.

You can also use the new get_home_url template tag retrieves the home url for a given site:

1
<?php get_home_url(); ?>

More info on get_home_url is also available in the codex.

Also new in WordPress 3.0 is admin_url and get_admin_url to retrieve the url to the admin area for a given site:

1
<?php get_admin_url(); ?>

There’s not much in the codex about these two yet, but check back at the Template Tags page for more soon.

Participate