[英]how do i get my wordpress website url with Colon ':' ..?
add_action( 'init', function() {
add_shortcode( 'site_url', function( $atts = null, $content = null ) {
return site_url();
});
});
I'm Using The Short Code [ site_url
] and My Short Code Function Returned https//shad-pro.com/contact-us
我正在使用短代码[
site_url
]和我的短代码功能返回https//shad-pro.com/contact-us
How Do I get The Proper Url
With Colon :
我如何使用冒号获得正确的
Url
:
First: Why do you create an add_action to init to make a shortcode?第一:你为什么要创建一个 add_action 到 init 来制作一个短代码?
Second, the function site_url () is deprecated by Wordpress for its native function home_url ().其次,函数 site_url() 被 Wordpress 弃用,因为它的原生函数 home_url()。
Try to correct the code as follows:尝试更正代码如下:
function create_site_url()
{
return home_url();
}
add_shortcode('site_url', 'create_site_url');
home_url() reference: https://codex.wordpress.org/Function_Reference/home_url home_url() 参考: https ://codex.wordpress.org/Function_Reference/home_url
add_shortcode() reference: https://codex.wordpress.org/Function_Reference/add_shortcode add_shortcode() 参考: https ://codex.wordpress.org/Function_Reference/add_shortcode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.