wordpress get_home_url() 只返回当前 URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10372944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:55:09  来源:igfitidea点击:

get_home_url() just returns current URL

wordpressurlwordpress-theming

提问by Sophistifunk

My problem is simple, I need a "home" link for my WP template, and the function get_home_url()is simply returning the current url. So if I'm on "example.com/?cat=2", that's the url I get for my home button .

我的问题很简单,我的 WP 模板需要一个“主页”链接,而该函数get_home_url()只是返回当前的 url。因此,如果我在 上"example.com/?cat=2",这就是我为主页按钮获得的网址。

Any ideas what I'm doing wrong? I'm pulling my hair out.

任何想法我做错了什么?我正在拔头发。

回答by maiorano84

It's just home_url(). So:

这只是 home_url()。所以:

echo home_url();

Will output the homepage of your Wordpress installation.

将输出您的 Wordpress 安装的主页。

回答by Tom Walters

Have you tried:

你有没有尝试过:

echo get_bloginfo('url')

回答by Goran Jakovljevic

You need to echo that function, so it should be:

您需要回显该功能,因此它应该是:

<?php echo get_home_url(); ?>