我可以获取“基本网址”吗?在WordPress中的模板文件中? [英] Can I get a "base URL" in WordPress within a template file?

查看:104
本文介绍了我可以获取“基本网址”吗?在WordPress中的模板文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,在我的PHP应用程序中,我设置了基本URL ,因此我可以执行以下操作

Usually in my PHP apps I have a base URL setup so I can do things like this

<a href="<?php echo BASE_URL; ?>tom/jones">Tom</a>

然后,我可以将站点从开发阶段转移到生产阶段,并轻松进行交换,并使更改遍及整个站点(而且它似乎比< base href = /> 更可靠。

Then I can move my site from development to production and swap it easily and have the change go site wide (and it seems more reliable than <base href="" />.

我在做一个WordPress主题,我想知道WordPress是否内置了这样的东西,还是我需要重新定义自己的东西?

I'm doing up a WordPress theme, and I am wondering, does WordPress have anything like this built in, or do I need to redefine my own?

我可以看到 ABSPATH ,但这是文件系统中的绝对文件路径,而不是文档根目录中的内容。

I can see ABSPATH, but that is the absolute file path in the file system, not something from the document root.

推荐答案

get_bloginfo('wpurl'); 是获取WordPress安装基本URL的首选方法,它始终返回安装的绝对基本URL其中, get_bloginfo('url'); 是WordPress安装的实际博客地址。

get_bloginfo('wpurl'); would be the preferred method of getting the base url of your WordPress installation. This always returns the absolute base url for the install where as get_bloginfo('url'); is for the actual blog address of your WordPress install.

这篇关于我可以获取“基本网址”吗?在WordPress中的模板文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆