[wp-hackers] Why always absolute paths?

Otto otto at ottodestruct.com
Thu Apr 22 15:02:44 UTC 2010


On Thu, Apr 22, 2010 at 12:46 AM, Jon Brown <jbrown510 at gmail.com> wrote:
> Is there an equivalent to <?php bloginfo('template_directory');?> that points to the /wp-content folder?  It seems to me that it would at least provide a bridge for those that need it, like me, to make moving sites between domains easier?

In PHP, you should use the content_url() function. It works like this:
echo content_url('temp/whatever');

That will give you "http://example.com/wp-content/temp/whatever" as the output.

There's also plugins_url, admin_url, includes_url, site_url, home_url,
network_site_url, network_home_url, network_admin_url... These all do
the same basic thing for different URLs that you might need. Several
of these are new to 3.0, but many of them have been around since 2.6
or so.

-Otto


More information about the wp-hackers mailing list