WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is admin

Description

This Conditional Tag checks if the Dashboard or the administration panel is attempting to be displayed. It is a boolean function that will return true if the URL being accessed is in the admin section, or false for a front-end page.

This function does not verify whether the current user has permission to view the Dashboard or the administration panel. Use current_user_can() instead.

Usage

<?php is_admin(); ?>

Parameters

This tag does not accept any parameters.

Return Values

(boolean) 
True on success, false on failure.

Examples

if ( ! is_admin() ) {
     echo "You are viewing the theme";
} else {
     echo "You are viewing the WordPress Administration Panels";
}

Notes

  • is_admin() will return false when trying to access wp-login.php.
  • is_admin() will return true when trying to make an ajax request (both front-end and back-end requests)
  • is_admin() will return true for calls to load-scripts.php and load-styles.php.
  • is_admin() is not intended to be used for security checks. It will return true whenever the current URL is for a page on the admin side of WordPress. It does not check if the user is logged in, nor if the user even has access to the page being requested. It is a convenience function for plugins and themes to use for various purposes, but it is not suitable for validating secured requests.

Change Log

Since: 1.5.1

Source File

is_admin() is located in wp-includes/load.php.

Related

See also index of Function Reference and index of Template Tags.