【发布时间】:2023-03-09 11:54:01
【问题描述】:
我正在制作一个 WordPress 博客,我必须经常更改站点 URL 以进行测试。有没有一种有效的方法可以将博客的当前主页 URL 动态插入到帖子中?
例如我想做这样的事情:
[button link="[current_site_url]/about/" size="large"]About[/button]
【问题讨论】:
我正在制作一个 WordPress 博客,我必须经常更改站点 URL 以进行测试。有没有一种有效的方法可以将博客的当前主页 URL 动态插入到帖子中?
例如我想做这样的事情:
[button link="[current_site_url]/about/" size="large"]About[/button]
【问题讨论】:
我认为<?php bloginfo('url'); ?> 是你要找的...
您还可以使用
获取模板目录的 url<?php bloginfo('template_directory'); ?>
要查看bloginfo的其他参数请参考;
【讨论】:
这里有一些例子:
//All these functions return the blog's URL as configured in Settings
site_url(); // Does not display the URL
get_bloginfo('url'); // Does not display the URL
bloginfo('url'); // Always displays the URL
// Returns the root directory URL
// For http://example.com/myblog returns http://example.com
home_url(); // Does not display the URL
【讨论】: