问题描述
我正在尝试在WordPres中将网站网址和管理网址作为简码。
我正在使用的代码写在下面。
//Website URL shortcode [site_url]
add_action( 'init',function() {
add_shortcode( 'site_url',function( $atts = null,$content = null ) {
return site_url();
} );
} );
//Website admin URL shortcode [admin_url]
add_action( 'init',function() {
add_shortcode( 'admin_url',$content = null ) {
return admin_url();
} );
} );
现在的问题是,当我使用[site_url]或[admin_url]时,它显示URL https // mysitename.com。表示链接在URL中没有“:”
我尝试使用下面的代码将https //替换为https://,但是那也不起作用...
//Replace text
function replace_text($my_text_replace) {
$my_text_replace = str_replace('https//','https://',$my_text_replace);
$my_text_replace = str_replace('https//https//',$my_text_replace);
return $my_text_replace;
}
add_filter('the_content','replace_text');
请提出任何建议。
谢谢
解决方法
我认为您应该在wp_options表中检查数据库内部的这两个键的值:“ home”和“ siteurl”。由于这些函数实际上是读取该值的,所以进入数据库并确保100%不会错过那里的双点