wordpress 获取当前文章 url地址

functioncurrent_page_url() {
    $pageURL= 'http';
    if( isset($_SERVER["HTTPS"]) ) {
        if($_SERVER["HTTPS"] == "on") {$pageURL.= "s";}
    }
    $pageURL.= "://";
    if($_SERVER["SERVER_PORT"] != "80") {
        $pageURL.= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    }else{
        $pageURL.= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return$pageURL;
}




把PHP代码放到 include/functions.php文件里,然后在模版输出即可!
web开发

你可能感兴趣的:(技术文章)