WordPress Path Functions: List WordPress Theme, Plugin, Site URL and Absolute Path in Server – WordPress Tutorial

By | April 4, 2020

When we are developing a wordpress theme or plugin, we have to get some wordpress path information. such as the absolute path of wordpress theme, plugin, style file or home url. In this tutoral, we will introduce some wordpress path functions to get these path or url information.

About wordpress site


It will return the home url of a site. For example:

$url = home_url();
echo $url;
//output: http://www.example.com

$url = home_url('/linux/');
echo $url;
//output: http://www.example.com/linux/

To learn more on home_url(), you can read this tutorial.

Understand WordPress home_url() for Beginngers – WordPress Tutorial


This function returns the home url of a wordpress site, which may be not the same to home_url(). For example, if you created a wordpress site in a blog folder. You will see:

$url = site_url();
echo  $url;

$url = home_url();
echo  $url;


It returns the wordpress dashboard admin url.

$url = admin_url();
echo $url;
//output: http://www.example.com/wp-admin/


This function returns the url of wp-content folder.

$url = content_url();
echo  $url;
//output: http://www.example.com/wp-content


This function returns the url of wp-includes folder.

$url = includes_url();
echo $url;
//output: http://www.example.com/wp-includes/

$url = includes_url( '/js/');
echo $url;
//output: http://www.example.com/wp-includes/js/


It returns the url of wordpress uploads folder.

$upload_dir = wp_upload_dir();
echo $upload_dir['baseurl'];
//output: http://www.example.com/wp-content/uploads

About wordpress theme path function


It returns the url of wordpress themes folder.

echo get_theme_root_uri();
//output: http://www.example.com/wp-content/themes


This function returns the absolute path of themes folder in server.

echo get_theme_root();
//output: /home/user/public_html/wp-content/themes


This function returns the absolute path of current wordpress theme in server.

echo get_stylesheet_directory();
//output: /home/user/public_html/wp-content/themes/twentyeleven


This function returns the url of current theme.

echo get_stylesheet_directory_uri();
//output: http://www.example.com/wp-content/themes/twentyeleven

About wordpress plugin path function


This function returns the url of  plugins folder.

echo plugins_url();
//output: http://www.example.com/wp-content/plugins


This function is same to plugins_url().

echo plugin_dir_url(__FILE__ );
//output: http://www.example.com/wp-content/plugins


It returns the absolute path of current plugin folder in server.

echo plugin_dir_path(__FILE__ );