is_admin()
Whether the current request is for an administrative interface page.
Does not check if the user is an administrator; use current_user_can() for checking roles and capabilities.
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
1 time — 0.000014 sec (very fast) | 50000 times — 0.01 sec (speed of light) | PHP 7.0.14, WP 4.7
No Hooks.
Return
true|false
. True if inside WordPress administration interface, false otherwise.
Usage
is_admin();
Examples
#1 An example of the definition of the front end and the admin area of the site:
if ( is_admin() ) { echo 'You are in the admin area'; } else { echo 'You are browsing the front-end of the site (topic)'; }
Notes
- Global. WP_Screen. $current_screen WordPress current screen object.
Changelog
Since 1.5.1 | Introduced. |
is_admin() is admin code WP 6.8
function is_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin(); } elseif ( defined( 'WP_ADMIN' ) ) { return WP_ADMIN; } return false; }