简体   繁体   中英

Site URL and Admin URL shortcode issue in wordpress

I am trying have site url and admin url as shortcode in wordpres.

Code I am using is written below.

//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', function( $atts = null, $content = null ) {
        return admin_url();
        } );
    } );

Now the issue is, when I use [site_url] or [admin_url] it show url https//mysitename.com. Mean the link is without ":" in URL

I tried to use code below to replace https// with https:// but that one also not working...

//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//', 'https://', $my_text_replace);
    return $my_text_replace;
}
add_filter('the_content', 'replace_text');

Any suggestion please..

Thanks

I think you should check inside your database, in wp_options table the values of this 2 key: "home" and "siteurl". Since those functions actually read that value, go in the database and make sure 100% you didn't miss the double dots there

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM