如果是登录页面,有没有比使用全局变量$pagenow
更好的方法来检测当前页面,就像is_admin()
函数一样?
if ($pagenow != 'wp-login.php' && !is_admin())
{
// Do something
}
有一个带有getter get_current_screen()
(在/wp-admin/includes/template.php
中声明)的全局变量$current_screen
,但它始终等于null
。
在#15686 (Detect the current page template tag) – WordPress Trac上,它显示通常使用$pagenow
,但我认为这不是比较非动态页面与文件名而不是函数(如管理页面)的好方法。
https://stackoverflow.com/questions/5266945
复制相似问题