admin管理员组文章数量:1415491
Both functions return the website url.
And, as home_url() needs sanitization (for example <?php echo esc_url( home_url( '/' ) ); ?>)
, why it is this snippet of code, instead of <?php echo get_ home_url( '/' ); ?>
, that we found in Wordpress Codex and Wordpress Template Twenty Nineteen ?
Both functions return the website url.
And, as home_url() needs sanitization (for example <?php echo esc_url( home_url( '/' ) ); ?>)
, why it is this snippet of code, instead of <?php echo get_ home_url( '/' ); ?>
, that we found in Wordpress Codex and Wordpress Template Twenty Nineteen ?
- Welcome to WordPress Development. I hope you find the answer(s) you are looking for. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. – Matthew Brown aka Lord Matt Commented Sep 13, 2019 at 10:10
- 1 Thanks. I will check your tour. – PhpDoe Commented Sep 13, 2019 at 10:46
2 Answers
Reset to default 2There isn't much difference but they are not the same.
get_home_url
get_home_url()
takes null or a blog id as the first parameter. As per documentation here.
get_home_url( int $blog_id = null, string $path = '', string|null $scheme = null )
If you are dealing with multiple homes (as in, say a multi-site set up) this might be useful.
home_url
home_url()
, on the other hand, is less fussed about per blog settings and just wants the home URL. As per documentation here.
home_url( string $path = '', string|null $scheme = null )
It is the equivalent of calling get_home_url( null, $path, $scheme );
. Most of the time, this is the function you want.
There is no difference. If you look at wordpress code you will see
function home_url( $path = '', $scheme = null ) {
return get_home_url( null, $path, $scheme );
}
本文标签: home urlWhat39s the difference between homeurl() and gethomeurl() from a developmental point of view
版权声明:本文标题:home url - What's the difference between home_url() and get_home_url() from a developmental point of view? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745161638a2645466.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论