WordPress has defined some constant variables for file url and absolute path in web server, these constant variables are very useful to create a wordpress theme and plugin. In this tutorial, we will introduce some common used constant variables for beginners.
WP_CONTENT_DIR
This constant variable is the absolute path of wp-content folder in server.
<?php echo WP_CONTENT_DIR; //output: /home/user/public_html/wp-content ?>
WP_CONTENT_URL
This constant variable is the url of wp-content folder.
<?php echo WP_CONTENT_URL; //output: http://www.example.com/wp-content ?>
WP_PLUGIN_DIR
This constant variable is the absolute path of wordpress plugins folder in web server.
<?php echo WP_PLUGIN_DIR; //output: /home/user/public_html/wp-content/plugins ?>
WP_PLUGIN_URL
This constant variable is the url of wordpress plugins folder.
<?php echo WP_PLUGIN_URL; //output: http://www.example.com/wp-content/plugins ?>
TEMPLATEPATH
This constant variable is the absolute path of current wordpress theme in server.
<?php echo TEMPLATEPATH; //output: /home/user/public_html/wp-content/themes/twentyeleven ?>