WordPress 3.0 New Template Tags for Home and Admin URLs

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:

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

Free Video Why 100 is NOT a Perfect Google PageSpeed Score (*5 Min Watch) Learn how to use Google PageSpeed Insights to set realistic goals, improve site speed, and why aiming for a perfect 100 is the WRONG goal.
Tags: