原文:
https://blog.csdn.net/u011675745/article/details/52791703
開發wordpress主題或者插件的時候,最忌諱的一點就是把地址寫死了。這樣的主題或者插件除了自己能用之外,別人根本就用不了。所以,強烈建議在需要使用地址和URL的場合使用Wordpress自帶的各類用於查詢地址和URL的函數
站點路徑相關函數
home_url()
site_url()
admin_url()
content_url()
includes_url()
wp_upload_dir()
主題路徑相關函數
get_theme_root_uri()
get_theme_root()
get_theme_roots()
get_stylesheet_directory()
get_stylesheet_directory_uri()
get_template_directory_uri()
get_template_directory()
get_template()
get_stylesheet()
plugins_url()
plugin_dir_url()
plugin_dir_path()
plugin_basename()
路徑相關常量
WP_CONTENT_DIR
WP_CONTENT_URL
WP_PLUGIN_DIR
WP_PLUGIN_URL
TEMPLATEPATH
STYLESHEETPATH