返回介绍

home_url()

发布于 2017-09-11 00:55:10 字数 8546 浏览 1203 评论 0 收藏 0

home_url( string $path = '',  string|null $scheme = null )

Retrieves the URL for the current site where the front end is accessible.


description

Returns the ‘home’ option with the appropriate protocol. The protocol will be ‘https’ if is_ssl() evaluates to true; otherwise, it will be the same as the ‘home’ option. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.


参数

$path

(string) (Optional) Path relative to the home URL.

Default value: ''

$scheme

(string|null) (Optional) Scheme to give the home URL context. Accepts 'http', 'https', 'relative', 'rest', or null.

Default value: null


返回值

(string) Home URL link with optional path appended.


源代码

File: wp-includes/link-template.php

function home_url( $path = '', $scheme = null ) {
	return get_home_url( null, $path, $scheme );
}

更新日志

Versiondescription
3.0.0Introduced.

相关函数

Uses

  • wp-includes/link-template.php: get_home_url()

Used By

  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::is_cross_domain()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::get_allowed_urls()
  • wp-includes/theme.php: get_theme_starter_content()
  • wp-includes/embed.php: the_embed_site_title()
  • wp-includes/general-template.php: get_custom_logo()
  • wp-includes/embed.php: get_post_embed_url()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::get_preview_url()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::get_return_url()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_pane_settings()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::set_preview_url()
  • wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::get_index()
  • wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::load_available_items_query()
  • wp-admin/includes/class-wp-press-this.php: WP_Press_This::html()
  • wp-login.php: login_footer()
  • wp-signup.php: confirm_another_blog_signup()
  • wp-admin/includes/class-wp-automatic-updater.php: WP_Automatic_Updater::send_email()
  • wp-admin/includes/dashboard.php: wp_check_browser_version()
  • wp-admin/includes/dashboard.php: wp_welcome_panel()
  • wp-admin/includes/nav-menu.php: wp_nav_menu_item_post_type_meta_box()
  • wp-admin/includes/import.php: wp_get_popular_importers()
  • wp-admin/includes/user.php: admin_created_user_email()
  • wp-admin/custom-header.php: Custom_Image_Header::step_1()
  • wp-admin/custom-background.php: Custom_Background::admin_page()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_preview_settings()
  • wp-includes/theme.php: wp_customize_support_script()
  • wp-includes/category-template.php: wp_list_categories()
  • wp-includes/theme.php: _wp_customize_loader_settings()
  • wp-includes/formatting.php: wp_rel_nofollow_callback()
  • wp-includes/pluggable.php: wp_validate_redirect()
  • wp-includes/general-template.php: wp_get_archives()
  • wp-includes/general-template.php: get_bloginfo()
  • wp-includes/general-template.php: get_search_form()
  • wp-includes/deprecated.php: wp_admin_bar_dashboard_view_site_menu()
  • wp-includes/class-wp.php: WP::parse_request()
  • wp-includes/functions.php: wp_get_referer()
  • wp-includes/widgets/class-wp-widget-rss.php: WP_Widget_RSS::widget()
  • wp-includes/widgets/class-wp-widget-categories.php: WP_Widget_Categories::widget()
  • wp-includes/taxonomy.php: get_term_link()
  • wp-includes/link-template.php: wp_get_shortlink()
  • wp-includes/link-template.php: network_home_url()
  • wp-includes/link-template.php: get_pagenum_link()
  • wp-includes/link-template.php: get_post_type_archive_link()
  • wp-includes/link-template.php: get_term_feed_link()
  • wp-includes/link-template.php: get_search_link()
  • wp-includes/link-template.php: get_month_link()
  • wp-includes/link-template.php: get_day_link()
  • wp-includes/link-template.php: get_feed_link()
  • wp-includes/link-template.php: get_post_comments_feed_link()
  • wp-includes/link-template.php: get_author_feed_link()
  • wp-includes/link-template.php: get_permalink()
  • wp-includes/link-template.php: get_post_permalink()
  • wp-includes/link-template.php: get_page_link()
  • wp-includes/link-template.php: _get_page_link()
  • wp-includes/link-template.php: get_attachment_link()
  • wp-includes/link-template.php: get_year_link()
  • wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::initialize()
  • wp-includes/update.php: wp_version_check()
  • wp-includes/http.php: get_allowed_http_origins()
  • wp-includes/class-oembed.php: WP_oEmbed::__construct()
  • wp-includes/admin-bar.php: wp_admin_bar_site_menu()
  • wp-includes/admin-bar.php: wp_admin_bar_my_sites_menu()
  • wp-includes/admin-bar.php: wp_admin_bar_search_menu()
  • wp-includes/feed.php: self_link()
  • wp-includes/user.php: wp_update_user()
  • wp-includes/nav-menu-template.php: _wp_menu_item_classes_by_context()
  • wp-includes/post-template.php: wp_page_menu()
  • wp-includes/post.php: is_local_attachment()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::mod_rewrite_rules()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::iis7_url_rewrite_rules()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::rewrite_rules()
  • wp-includes/rewrite.php: url_to_postid()
  • wp-includes/canonical.php: redirect_canonical()
  • wp-includes/canonical.php: wp_redirect_admin_locations()
  • wp-includes/ms-functions.php: maybe_add_existing_user_to_blog()
  • wp-includes/author-template.php: get_author_posts_url()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getUsersBlogs()
  • wp-includes/comment.php: weblog_ping()
  • wp-includes/comment.php: wp_set_comment_cookies()
  • Show 73 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Example

    
    $url = home_url();
    echo $url;
    

    Output: http://www.example.com

    (Note the lack of a trailing slash)

    
    $url = home_url( '/' );
    echo $url;
    

    Output: http://www.example.com/

    
    $url = home_url( $path = '/', $scheme = https );
    echo $url;
    

    Output: https://www.example.com/

    
    $url = home_url( $path = 'example', $scheme = relative );
    echo $url;
    

    Output: /example

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文