Top

Daily Tip: WordPress 3.0 New Template Tags for Home and Admin URLs

June 28, 2010

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:

<?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:

<?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:

<?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.

Tweet This Post


Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.