I often need to include a directory or URL path when writing a theme or plugin, but I can never find all of the different options in one place, so I’m pulling it together from various Codex pages and xref.
Constants
- ABSPATH – /var/www/vhosts/example.com/httpdocs/
- WP_CONTENT_DIR – /var/www/vhosts/example.com/httpdocs/wp-content
- WP_CONTENT_URL – http://www.example.com/wp-content
- WP_PLUGIN_DIR – /var/www/vhosts/example.com/httpdocs/wp-content/plugins
- WP_PLUGIN_URL – http://www.example.com/wp-content/plugins
- TEMPLATEPATH – /var/www/vhosts/example.com/httpdocs/wp-content/themes/parent-theme
- STYLESHEETPATH – /var/www/vhosts/example.com/httpdocs/wp-content/themes/child-theme
- BLOGUPLOADDIR – /var/www/vhosts/example.com/httpdocs/wp-content/blogs.dir/{blogid}/files/ (multisite only)
bloginfo() Parameters
- template_directory – http://www.example.com/wp-content/themes/parent-theme
- template_url – http://www.example.com/wp-content/themes/parent-theme [1]
- stylesheet_directory – http://www.example.com/wp-content/themes/child-theme
- stylesheet_url – http://www.example.com/wp-content/themes/child-theme/style.css
Miscellaneous Functions
- site_url() / home_url() – http://www.example.com [2]
- admin_url() – http://www.example.com/wp-admin/
[1] You might expect bloginfo(‘template_url’) to be consistent with bloginfo(‘stylesheet_url’) and return the URL to the parent theme’s style.css. You’d be wrong. It gives you the directory, just like bloginfo(‘template_directory’)…
[2] It’s better to use these instead of bloginfo(‘url’) and bloginfo(‘wpurl’) because they’ll return an HTTPS URL when appropriate. If you’re going to be using it multiple times on a page it’s more efficient to assign it to a variable instead of calling it over and over.
Hi Ian
Thank you for this article, I had a case where bloginfo(‘url’) was breaking my code for no apparent reason, and site_url() just saved the day!
Best Regards
Francois