is_admin(): bool

Determines whether the current request is for an administrative interface page.


Description

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.


Top ↑

Return

bool True if inside WordPress administration interface, false otherwise.


Top ↑

Source

File: wp-includes/load.php. View all references

function is_admin() {
	if ( isset( $GLOBALS['current_screen'] ) ) {
		return $GLOBALS['current_screen']->in_admin();
	} elseif ( defined( 'WP_ADMIN' ) ) {
		return WP_ADMIN;
	}

	return false;
}


Top ↑

Changelog

Changelog
Version Description
1.5.1 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 2 content
    Contributed by hearvox

    Example:

    if ( ! is_admin() ) {
        // Runs only if this PHP code is in a file that displays outside the admin panels, like the theme template.
        echo '<div style="text-align: center">Welcome to our website.</div>';
    } else {
        // Runs only if this code is in a file that displays inside the admin panels, like a plugin file.
        echo '<div style="text-align: center">Welcome to your Admin Panels.</div>';
    }
  2. Skip to note 5 content
    Contributed by Gary Jones

    is_admin() returns true for Ajax requests, since wp-admin/admin-ajax.php defines the WP_ADMIN constant as true.

You must log in before being able to contribute a note or feedback.