On this page
site_url( string $path = '', string|null $scheme = null ): string
Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
Description
Returns the ‘site_url’ option with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.
Parameters
$pathstring Optional-
Path relative to the site URL.
Default:
'' $schemestring|null Optional-
Scheme to give the site URL context. See set_url_scheme() .
More Arguments from set_url_scheme( ... $scheme )
Scheme to give $url. Currently'http','https','login','login_post','admin','relative','rest','rpc', or null.Default:
null
Return
string Site URL link with optional path appended.
Source
File: wp-includes/link-template.php. View all references
function site_url( $path = '', $scheme = null ) {
return get_site_url( null, $path, $scheme );
}
Related
Uses
| Uses | Description |
|---|---|
| get_site_url() wp-includes/link-template.php | Retrieves the URL for a given site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible. |
Used By
| Used By | Description |
|---|---|
| _wp_theme_json_webfonts_handler() wp-includes/script-loader.php | Runs the theme.json webfonts handler. |
| wp_is_local_html_output() wp-includes/https-detection.php | Checks whether a given HTML string is likely an output from this WordPress site. |
| wp_should_replace_insecure_home_url() wp-includes/https-migration.php | Checks whether WordPress should replace old HTTP URLs to the site with their HTTPS counterpart. |
| WP_Site_Health::can_perform_loopback() wp-admin/includes/class-wp-site-health.php | Runs a loopback test on the site. |
| load_script_textdomain() wp-includes/l10n.php | Loads the script translated strings. |
| wp_print_request_filesystem_credentials_modal() wp-admin/includes/file.php | Prints the filesystem credentials modal when needed. |
| spawn_cron() wp-includes/cron.php | Sends a request to run cron through HTTP request that doesn’t halt page loading. |
| get_theme_root_uri() wp-includes/theme.php | Retrieves URI for themes directory. |
| translate_smiley() wp-includes/formatting.php | Converts one smiley code to the icon graphic file equivalent. |
| rsd_link() wp-includes/general-template.php | Displays the link to the Really Simple Discovery service endpoint. |
| get_bloginfo() wp-includes/general-template.php | Retrieves information about the current site. |
| wp_logout_url() wp-includes/general-template.php | Retrieves the logout URL. |
| wp_login_url() wp-includes/general-template.php | Retrieves the login URL. |
| wp_registration_url() wp-includes/general-template.php | Returns the URL that allows the user to register on the site. |
| wp_login_form() wp-includes/general-template.php | Provides a simple login form for use anywhere within WordPress. |
| do_robots() wp-includes/functions.php | Displays the default robots.txt file content. |
| WP_Widget_RSS::widget() wp-includes/widgets/class-wp-widget-rss.php | Outputs the content for the current RSS widget instance. |
| includes_url() wp-includes/link-template.php | Retrieves the URL to the includes directory. |
| network_site_url() wp-includes/link-template.php | Retrieves the site URL for the current network. |
| get_the_password_form() wp-includes/post-template.php | Retrieves protected post password form content. |
| WP_Rewrite::mod_rewrite_rules() wp-includes/class-wp-rewrite.php | Retrieves mod_rewrite-formatted rewrite rules to write to .htaccess. |
| wp_redirect_admin_locations() wp-includes/canonical.php | Redirects a variety of shorthand URLs to the admin. |
| newblog_notify_siteadmin() wp-includes/ms-functions.php | Notifies the network admin that a new site has been activated. |
| wpmu_signup_user_notification() wp-includes/ms-functions.php | Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked. |
| wp_xmlrpc_server::blogger_getUsersBlogs() wp-includes/class-wp-xmlrpc-server.php | Retrieve blogs that user owns. |
| wp_xmlrpc_server::wp_getUsersBlogs() wp-includes/class-wp-xmlrpc-server.php | Retrieve the blogs of the user. |
| comment_form() wp-includes/comment-template.php | Outputs a complete commenting form for use within a template. |
| wp_default_styles() wp-includes/script-loader.php | Assigns default styles to $styles object. |
| wp_default_scripts() wp-includes/script-loader.php | Registers all WordPress scripts. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/site_url