StupidBeauty
Read times:733Posted at:Mon Jul 1 23:28:32 2013
- no title specified

转载WordPress中获取当前页面URL

可使用home_url函数来获取当前页面的URL。

http://www.ludou.org/how-to-get-the-current-url-in-wordpress.html

亮点:

子目录WP的方法

不过可惜的是,如果你的WordPress安装在子目录下,且站点地址也使用子目录(如:www.example.com/wp),那么以上代码就没法正常工作了。以下是针对此缺陷的修正代码,适用范围更加普遍:

1
2

global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));

未知美人

Your opinions
Your name:Email:Website url:Opinion content:
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4